Z score anthro Birth

##  [1] "birth_bfeed_prob_1"       "birth_condition_modified"
##  [3] "average_birth_circum"     "average_birth_length"    
##  [5] "average_birth_muac"       "average_birth_weight"    
##  [7] "cry_birth"                "baby_issue_birth"        
##  [9] "child_gender_final"       "hhid_int"                
## [11] "days_b"
## ================================================================================
## ================================================================================
## ================================================================================
## ================================================================================
## # A tibble: 3 × 2
##   underweight     n
##         <dbl> <int>
## 1           0    98
## 2           1    10
## 3          NA    34
## # A tibble: 3 × 2
##   stunting     n
##      <dbl> <int>
## 1        0   102
## 2        1     5
## 3       NA    35
## # A tibble: 3 × 2
##   wasting     n
##     <dbl> <int>
## 1       0    93
## 2       1    12
## 3      NA    37
## 
##    Low Birth Weight Normal Birth Weight 
##                  15                  93
##                      
##                        0  1
##   Low Birth Weight     5 10
##   Normal Birth Weight 93  0
## # A tibble: 142 × 20
##    birth_bfeed_prob_1 birth_condition_modified average_birth_circum
##    <dbl+lbl>                             <dbl>                <dbl>
##  1 NA                                       NA                 NA  
##  2 NA                                       NA                 NA  
##  3  0 [No]                                   0                 32  
##  4  0 [No]                                   1                 35.0
##  5  0 [No]                                   1                 33.4
##  6  0 [No]                                   1                 34.0
##  7  0 [No]                                   1                 33.4
##  8  0 [No]                                   1                 34.2
##  9  0 [No]                                   1                 33.8
## 10  0 [No]                                   1                 34.0
##    average_birth_length average_birth_muac average_birth_weight cry_birth     
##                   <dbl>              <dbl>                <dbl> <dbl+lbl>     
##  1                 NA                NA                   NA    NA            
##  2                 NA                NA                   NA    NA            
##  3                 47.7               9.3                  2.46  1 [Immediate]
##  4                 47.0               8.04                 2.83  2 [Delayed]  
##  5                 47.1               8.85                 2.49  1 [Immediate]
##  6                 50.8              11.2                  3.4   1 [Immediate]
##  7                 48.0               9.9                  2.48  1 [Immediate]
##  8                 52.8              10.4                  3.08  1 [Immediate]
##  9                 50.8               9.55                 3.06  2 [Delayed]  
## 10                 50.0              10.0                  2.89  1 [Immediate]
##    baby_issue_birth child_gender_final hhid_int days_b  wflz  wfaz  lfaz  hcaz
##               <dbl> <dbl+lbl>             <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>
##  1               NA NA                     2213      2 NA    NA    NA    NA   
##  2               NA NA                     1152      2 NA    NA    NA    NA   
##  3                1  2 [Female]            2514      2 -1.96 -1.75 -0.98 -1.76
##  4                1  1 [Male]               880      2  0.21 -1.1  -1.68  0.27
##  5                1  2 [Female]            1170      2 -1.4  -1.67 -1.28 -0.57
##  6                0  2 [Female]            1294      2 -0.38  0.4   0.68 -0.02
##  7                0  1 [Male]              2197      2 -2    -1.95 -1.15 -0.96
##  8                1  1 [Male]               597      2 -2.98 -0.53  1.35 -0.37
##  9                1  1 [Male]              2036      2 -1.52 -0.57  0.3  -0.69
## 10                0  1 [Male]              1321      2 -1.62 -0.95 -0.1  -0.49
##    stunting underweight wasting weight4length weight_category    
##       <dbl>       <dbl>   <dbl>         <dbl> <chr>              
##  1       NA          NA      NA       NA      <NA>               
##  2       NA          NA      NA       NA      <NA>               
##  3        0           0       0        0.0516 Low Birth Weight   
##  4        0           0       0        0.0602 Normal Birth Weight
##  5        0           0       0        0.0529 Low Birth Weight   
##  6        0           0       0        0.0670 Normal Birth Weight
##  7        0           0       0        0.0515 Low Birth Weight   
##  8        0           0       1        0.0584 Normal Birth Weight
##  9        0           0       0        0.0603 Normal Birth Weight
## 10        0           0       0        0.0578 Normal Birth Weight
## # ℹ 132 more rows
##  [1] "hhid_int"              "wflz_birth"            "wfaz_birth"           
##  [4] "lfaz_birth"            "hcaz_birth"            "stunting_birth"       
##  [7] "underweight_birth"     "wasting_birth"         "weight4length_birth"  
## [10] "weight_category_birth"

WHO 28 days

## ================================================================================
## ================================================================================
## ================================================================================
## ================================================================================
## 
##   0   1 
## 102  17
## 
##   0   1 
## 112   7
## 
##  0  1 
## 99 20
## # A tibble: 142 × 17
##    average_baby_circum average_baby_length.y average_baby_muac.y
##                  <dbl>                 <dbl>               <dbl>
##  1                NA                    NA                  NA  
##  2                NA                    NA                  NA  
##  3                36                    54.8                10.8
##  4                38.0                  52.2                12.0
##  5                36.4                  54.7                10.9
##  6                36.5                  56.2                12.1
##  7                37.4                  55.3                12.4
##  8                37                    56                  12.6
##  9                36.9                  57.0                12.4
## 10                36.7                  55.6                11.5
##    average_baby_weight.y average_baby_circum_plausible.y baby_issue_birth
##                    <dbl>                           <dbl>            <dbl>
##  1                 NA                               NA                 NA
##  2                 NA                               NA                 NA
##  3                  3.50                            36                  1
##  4                  3.94                            38.0                1
##  5                  3.95                            36.4                1
##  6                  4.39                            36.5                0
##  7                  4.66                            37.4                0
##  8                  4.57                            37                  1
##  9                  4.58                            36.9                1
## 10                  4.42                            36.7                0
##    child_gender_final hhid_int child_age_final  wflz  wfaz  lfaz  hcaz stunting
##    <dbl+lbl>             <dbl>           <dbl> <dbl> <dbl> <dbl> <dbl>    <dbl>
##  1 NA                     2213            NA   NA    NA    NA    NA          NA
##  2 NA                     1152            NA   NA    NA    NA    NA          NA
##  3  2 [Female]            2514            37.4 -2.87 -1.68  0.16 -0.82        0
##  4  1 [Male]               880            35.4  0.37 -1.25 -1.6   0.38        0
##  5  2 [Female]            1170            52.4 -1.39 -1.59 -0.73 -1.18        0
##  6  2 [Female]            1294            42.4 -1.16 -0.31  0.55 -0.65        0
##  7  1 [Male]              2197            50.4  0.08 -0.87 -0.96 -0.93        0
##  8  1 [Male]               597            53.4 -0.66 -1.18 -0.78 -1.46        0
##  9  1 [Male]              2036            48.4 -1.34 -0.9  -0.01 -1.3         0
## 10  1 [Male]              1321            50.4 -0.69 -1.28 -0.83 -1.61        0
##    underweight wasting weight4length
##          <dbl>   <dbl>         <dbl>
##  1          NA      NA       NA     
##  2          NA      NA       NA     
##  3           0       1        0.0640
##  4           0       0        0.0754
##  5           0       0        0.0722
##  6           0       0        0.0782
##  7           0       0        0.0843
##  8           0       0        0.0817
##  9           0       0        0.0805
## 10           0       0        0.0796
## # ℹ 132 more rows
## [1] "hhid_int"         "wflz_28"          "wfaz_28"          "lfaz_28"         
## [5] "hcaz_28"          "stunting_28"      "underweight_28"   "wasting_28"      
## [9] "weight4length_28"

Behavioral indicators and RSA

data %>% dplyr::select(bgc_baseline_n1_1_28, bgc_baseline_n2_1_28, bgm_baseline_n1_1_28, bgm_baseline_n2_1_28) %>% report_table()
## Variable             |   Level | n_Obs | percentage_Obs
## -------------------------------------------------------
## bgc_baseline_n1_1_28 |       1 |    21 |          14.79
## bgc_baseline_n1_1_28 |       2 |     8 |           5.63
## bgc_baseline_n1_1_28 |       3 |    20 |          14.08
## bgc_baseline_n1_1_28 |       4 |    14 |           9.86
## bgc_baseline_n1_1_28 |       5 |    43 |          30.28
## bgc_baseline_n1_1_28 |       6 |    11 |           7.75
## bgc_baseline_n1_1_28 | missing |    25 |          17.61
## bgc_baseline_n2_1_28 |       1 |    18 |          12.68
## bgc_baseline_n2_1_28 |       2 |    15 |          10.56
## bgc_baseline_n2_1_28 |       3 |    16 |          11.27
## bgc_baseline_n2_1_28 |       4 |    12 |           8.45
## bgc_baseline_n2_1_28 |       5 |    50 |          35.21
## bgc_baseline_n2_1_28 |       6 |     6 |           4.23
## bgc_baseline_n2_1_28 | missing |    25 |          17.61
## bgm_baseline_n1_1_28 |       1 |    17 |          11.97
## bgm_baseline_n1_1_28 |       2 |    12 |           8.45
## bgm_baseline_n1_1_28 |       3 |    27 |          19.01
## bgm_baseline_n1_1_28 |       4 |    11 |           7.75
## bgm_baseline_n1_1_28 |       5 |    35 |          24.65
## bgm_baseline_n1_1_28 |       6 |    15 |          10.56
## bgm_baseline_n1_1_28 | missing |    25 |          17.61
## bgm_baseline_n2_1_28 |       1 |    21 |          14.79
## bgm_baseline_n2_1_28 |       2 |    16 |          11.27
## bgm_baseline_n2_1_28 |       3 |    29 |          20.42
## bgm_baseline_n2_1_28 |       4 |     5 |           3.52
## bgm_baseline_n2_1_28 |       5 |    34 |          23.94
## bgm_baseline_n2_1_28 |       6 |    12 |           8.45
## bgm_baseline_n2_1_28 | missing |    25 |          17.61
data %>% 
  mutate(across(c(bgc_baseline_n1_1_28, bgc_baseline_n2_1_28, bgm_baseline_n1_1_28, 
                  bgm_baseline_n2_1_28, fussiness_1_28), as.numeric)) %>%
  
  # Calculate the average for bgc (Baseline Galvanic Conductance)
  mutate(bgc_avg = (bgc_baseline_n1_1_28 + bgc_baseline_n2_1_28) / 2,
         
         # Calculate the average for bgm (Baseline Galvanic Movement)
         bgm_avg = (bgm_baseline_n1_1_28 + bgm_baseline_n2_1_28) / 2,
         
         # Calculate the overall average of bgc and bgm
         bgc_bgm_avg = (bgc_avg + bgm_avg) / 2) %>% 
  correlation(p_adjust = "none", select = c("RSA_alone", "RSA_tog"), select2 = c("bgc_avg", "bgm_avg")) 
## # Correlation Matrix (pearson-method)
## 
## Parameter1 | Parameter2 |     r |         95% CI |     t |  df |       p
## ------------------------------------------------------------------------
## RSA_alone  |    bgc_avg | -0.33 | [-0.51, -0.13] | -3.18 |  80 | 0.002**
## RSA_alone  |    bgm_avg | -0.25 | [-0.44, -0.03] | -2.31 |  80 | 0.024* 
## RSA_tog    |    bgc_avg | -0.21 | [-0.39, -0.01] | -2.11 | 100 | 0.037* 
## RSA_tog    |    bgm_avg | -0.23 | [-0.41, -0.04] | -2.38 | 100 | 0.019* 
## 
## p-value adjustment method: none
## Observations: 82-102
data <- data %>%
  mutate(bgc_avg = rowMeans(cbind(bgc_baseline_n1_1_28, bgc_baseline_n2_1_28), na.rm = TRUE),# Calculate the average for bgm, ignoring NA values
         bgm_avg = rowMeans(cbind(bgm_baseline_n1_1_28, bgm_baseline_n2_1_28), na.rm = TRUE))

library(ggplot2)

describe_distribution(data$bgc_avg)
## Mean |   SD | IQR |        Range | Skewness | Kurtosis |   n | n_Missing
## ------------------------------------------------------------------------
## 3.69 | 1.57 |   3 | [1.00, 6.00] |    -0.44 |    -1.21 | 117 |        25
describe_distribution(data$bgm_avg)
## Mean |   SD | IQR |        Range | Skewness | Kurtosis |   n | n_Missing
## ------------------------------------------------------------------------
## 3.56 | 1.53 |   3 | [1.00, 6.00] |    -0.19 |    -1.16 | 117 |        25
p1 <- data %>% 
  ggplot(aes(bgc_avg, RSA_alone)) +
  geom_point(size = 4, colour = "#0072B2")+
  geom_smooth(method = "lm", size = 1, color = "black", alpha = 0.2) + theme_modern() + 
  labs(
    x = "Predominant Baseline State (r = -.33)",
    y = "Infant Solo Baseline RSA"
  ) +  scale_y_continuous(breaks = seq(1, 6, 0.5), expand = expansion(mult = 0.05)) +  # More detailed RSA scale
  scale_x_continuous(breaks = scales::pretty_breaks(n = 5))

p2 <- data %>% 
  ggplot(aes(bgm_avg, RSA_tog)) +
  geom_point(size = 4, colour = "maroon")+
  geom_smooth(method = "lm", size = 1, color = "black", alpha = 0.2) + theme_modern() + 
  labs(
    x = "Predominant Baseline State (r = -.23)",
    y = "Mom Infant Joint RSA"
  ) +  scale_y_continuous(breaks = seq(1, 6, 0.5), expand = expansion(mult = 0.05)) +  # More detailed RSA scale
  scale_x_continuous(breaks = scales::pretty_breaks(n = 5))

see::plots(p2,p1, n_columns = 1, title = "Associations between baseline behavioral indicators & Infant RSA", subtitle = "Higher scores denote more arousal")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

ggsave("RSAArousal.png", width = 4.5, height = 7, unit = "in", dpi = 300, bg = 'white')
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
# Assign states based on ranges of bgc_avg values
data <- data %>%
  mutate(bgc_state = case_when(
    bgc_avg >= 0.5 & bgc_avg < 1.5 ~ "State 1: Eyes closed, regular breathing, no activity",
    bgc_avg >= 1.5 & bgc_avg < 2.5 ~ "State 2: Eyes closed, irregular respiration, small movements",
    bgc_avg >= 2.5 & bgc_avg < 3.5 ~ "State 3: Drowsy; minimal activity",
    bgc_avg >= 3.5 & bgc_avg < 4.5 ~ "State 4: Alert, orienting to mother or object",
    bgc_avg >= 4.5 & bgc_avg < 5.5 ~ "State 5: Medium motor activity, brief fussiness",
    bgc_avg >= 5.5 ~ "State 6: Crying; high motor activity",
    TRUE ~ NA_character_  # Handle cases that don't fit
  ))

# Assign states for BGM similarly
data <- data %>%
  mutate(bgm_state = case_when(
    bgm_avg >= 0.5 & bgm_avg < 1.5 ~ "State 1: Eyes closed, regular breathing, no activity",
    bgm_avg >= 1.5 & bgm_avg < 2.5 ~ "State 2: Eyes closed, irregular respiration, small movements",
    bgm_avg >= 2.5 & bgm_avg < 3.5 ~ "State 3: Drowsy; minimal activity",
    bgm_avg >= 3.5 & bgm_avg < 4.5 ~ "State 4: Alert, orienting to mother or object",
    bgm_avg >= 4.5 & bgm_avg < 5.5 ~ "State 5: Medium motor activity, brief fussiness",
    bgm_avg >= 5.5 ~ "State 6: Crying; high motor activity",
    TRUE ~ NA_character_
  ))


# Step 1: Filter the data to ensure complete cases for RSA and bgc_state
complete_data <- data %>% filter(!is.na(RSA_alone) & !is.na(bgc_state))

# Step 2: Regress RSA on state using the filtered data
rsa_state_model <- lm(RSA_alone ~ bgc_avg, data = complete_data)

# Step 3: Extract residuals
complete_data$rsa_residual_alone <- resid(rsa_state_model)

# Step 4: Merge the residuals back into the original dataset
# Add the residuals back to the full dataset, filling with NA where data was missing
data <- data %>%
  left_join(complete_data %>% select(hhid_int, rsa_residual_alone), by = "hhid_int")  # Assuming hhid_int is a unique identifier



library(stringr)


# Shorten the labels for better display in the legend
wrapped_labels <- str_wrap(c(
  "State 1: Eyes closed, regular breathing, no activity",
  "State 2: Eyes closed, irregular respiration, small movements",
  "State 3: Drowsy; minimal activity",
  "State 4: Alert, orienting to mother or object",
  "State 5: Medium motor activity, brief fussiness",
  "State 6: Crying; high motor activity"
), width = 25)

# Define colors for each state
state_colors <- c(
  "State 1: Eyes closed, regular breathing, no activity" = "#a6cee3",
  "State 2: Eyes closed, irregular respiration, small movements" = "#1f78b4",
  "State 3: Drowsy; minimal activity" = "#b2df8a",
  "State 4: Alert, orienting to mother or object" = "#33a02c",
  "State 5: Medium motor activity, brief fussiness" = "#fb9a99",
  "State 6: Crying; high motor activity" = "#e31a1c"
)

# Set factor levels to ensure consistency in the ordering
all_states <- names(state_colors)

# Apply factor levels to both bgc_state and bgm_state
data$bgc_state <- factor(data$bgc_state, levels = all_states)
data$bgm_state <- factor(data$bgm_state, levels = all_states)

# Reshape the data for the stacked bar plot (long format)
stacked_data <- data %>%
  select(bgc_state, bgm_state) %>%
  pivot_longer(cols = c(bgc_state, bgm_state), names_to = "Measurement", values_to = "State")

# Remove rows with NA in the 'State' column
stacked_data_clean <- stacked_data %>%
  filter(!is.na(State))

# Calculate counts and proportions for each state in bgc and bgm
stacked_data_clean <- stacked_data_clean %>%
  group_by(Measurement, State) %>%
  summarise(count = n(), .groups = 'drop') %>%
  group_by(Measurement) %>%
  mutate(percentage = count / sum(count) * 100)  # Calculate percentage for each state

# Create the stacked bar plot with percentage labels and custom colors
stacked_plot_clean <- ggplot(stacked_data_clean, aes(x = Measurement, y = count, fill = State)) +
  geom_bar(stat = "identity", position = "stack", color = "black", alpha = 0.8) +  # Stacked bars with black outline
  geom_text(aes(label = sprintf("%.1f%%", percentage)),  # Add percentage labels
            position = position_stack(vjust = 0.5), size = 3) +  # Position text in the middle of each stack
  scale_fill_manual(values = state_colors, labels = wrapped_labels) +  # Use custom colors and wrapped labels
  labs(title = "Stacked Bar Plot of BGC and BGM States with Percentages",
       x = "Measurement",
       y = "Count",
       fill = "State") +  # Label the legend
  scale_x_discrete(labels = c("bgc_state" = "State - Alone", "bgm_state" = "State - Joint baseline")) +  # Relabel x-axis
  theme_minimal() +  # Minimal theme for a clean look
  theme(
    plot.title = element_text(size = 14, face = "bold"),  # Customize the title
    axis.title.x = element_text(size = 12),  # Customize x-axis title
    axis.title.y = element_text(size = 12),  # Customize y-axis title
    legend.position = "right",  # Adjust legend position
    legend.text = element_text(size = 8)  # Adjust legend text size
  )

# Display the plot
print(stacked_plot_clean)

# Reshape the data for the stacked bar plot (long format)
stacked_data <- data %>%
  select(bgc_state, bgm_state, date_category) %>%  # Include date_category in the data
  pivot_longer(cols = c(bgc_state, bgm_state), names_to = "Measurement", values_to = "State")

# Remove rows with NA in the 'State' column
stacked_data_clean <- stacked_data %>%
  filter(!is.na(State))

# Calculate counts and proportions for each state in bgc and bgm
stacked_data_clean <- stacked_data_clean %>%
  group_by(Measurement, State, date_category) %>%  # Group by date_category for faceting
  summarise(count = n(), .groups = 'drop') %>%
  group_by(Measurement, date_category) %>%
  mutate(percentage = count / sum(count) * 100)  # Calculate percentage for each state within date_category

# Create the stacked bar plot with percentage labels and custom colors, faceted by date_category
stacked_plot_clean <- ggplot(stacked_data_clean, aes(x = Measurement, y = count, fill = State)) +
  geom_bar(stat = "identity", position = "stack", color = "black", alpha = 0.8) +  # Stacked bars with black outline
  geom_text(aes(label = sprintf("%.1f%%", percentage)),  # Add percentage labels
            position = position_stack(vjust = 0.5), size = 3) +  # Position text in the middle of each stack
  scale_fill_manual(values = state_colors, labels = wrapped_labels) +  # Use custom colors and wrapped labels
  labs(title = "Changes in arousal leves after we adjusted the protocol", 
       x = "Measurement", 
       y = "Count", 
       fill = "State") +  # Label the legend
  scale_x_discrete(labels = c("bgc_state" = "State - Alone", "bgm_state" = "State - Joint baseline")) +  # Relabel x-axis
  theme_minimal() +  # Minimal theme for a clean look
  theme(
    plot.title = element_text(size = 14, face = "bold"),  # Customize the title
    axis.title.x = element_text(size = 12),  # Customize x-axis title
    axis.title.y = element_text(size = 12),  # Customize y-axis title
    legend.position = "right",  # Adjust legend position
    legend.text = element_text(size = 8),
    strip.text = element_text(size = 14)# Adjust legend text size
  ) +
  facet_wrap(~ date_category)  # Create panels for each date_category

# Display the plot
print(stacked_plot_clean)

ggsave("Arousal.png", width = 7, height = 6, unit = "in", dpi = 300, bg = 'white')


table(data$bgm_qus_face_1_28)
## 
##   0   1 
## 105  14
lessR::tt_brief(RSA_tog  ~ bgm_qus_face_1_28, data = data)
## 
## Compare RSA_tog across bgm_qus_face_1_28 with levels 0 and 1 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  bgm_qus_face_1_28, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for bgm_qus_face_1_28 0:  n.miss = 14,  n = 91,  mean = 2.661441195,  sd = 1.037933263
## RSA_tog for bgm_qus_face_1_28 1:  n.miss = 1,  n = 13,  mean = 1.963242510,  sd = 0.750062987
## 
## Mean Difference of RSA_tog:  0.698198686
## Weighted Average Standard Deviation:   1.008340829 
## Standardized Mean Difference of RSA_tog: 0.692423302
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.983 
## Standard Error of Mean Difference: SE =  0.298972780 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 2.335,  df = 102,  p-value = 0.021
## 
## Margin of Error for 95% Confidence Level:  0.593011092
## 95% Confidence Interval for Mean Difference:  0.105187594 to 1.291209778

#table(data$bgm_qus_kissing_1_28)
#lessR::tt_brief(RSA_tog  ~ bgm_qus_kissing_1_28, data = data)

table(data$bgm_qus_bfeed_1_28)
## 
##   0   1 
## 113   6
lessR::tt_brief(RSA_tog  ~ bgm_qus_bfeed_1_28, data = data)
## 
## Compare RSA_tog across bgm_qus_bfeed_1_28 with levels 0 and 1 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  bgm_qus_bfeed_1_28, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for bgm_qus_bfeed_1_28 0:  n.miss = 15,  n = 98,  mean = 2.613422841,  sd = 1.035725121
## RSA_tog for bgm_qus_bfeed_1_28 1:  n.miss = 0,  n = 6,  mean = 1.932977172,  sd = 0.718538334
## 
## Mean Difference of RSA_tog:  0.680445669
## Weighted Average Standard Deviation:   1.022472780 
## Standardized Mean Difference of RSA_tog: 0.665490253
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.983 
## Standard Error of Mean Difference: SE =  0.430011194 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 1.582,  df = 102,  p-value = 0.117
## 
## Margin of Error for 95% Confidence Level:  0.852925165
## 95% Confidence Interval for Mean Difference:  -0.172479496 to 1.533370834

table(data$bgm_qus_rocking_1_28)
## 
##  0  1 
## 57 62
lessR::tt_brief(RSA_tog  ~ bgm_qus_rocking_1_28, data = data)
## 
## Compare RSA_tog across bgm_qus_rocking_1_28 with levels 0 and 1 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  bgm_qus_rocking_1_28, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for bgm_qus_rocking_1_28 0:  n.miss = 4,  n = 53,  mean = 2.612914237,  sd = 1.083390440
## RSA_tog for bgm_qus_rocking_1_28 1:  n.miss = 11,  n = 51,  mean = 2.533898958,  sd = 0.980379982
## 
## Mean Difference of RSA_tog:  0.079015279
## Weighted Average Standard Deviation:   1.034177979 
## Standardized Mean Difference of RSA_tog: 0.076403946
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.983 
## Standard Error of Mean Difference: SE =  0.202856502 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.390,  df = 102,  p-value = 0.698
## 
## Margin of Error for 95% Confidence Level:  0.402364910
## 95% Confidence Interval for Mean Difference:  -0.323349632 to 0.481380189

table(data$bgm_qus_stroking_1_28)
## 
##   0   1 
## 107  12
lessR::tt_brief(RSA_tog  ~ bgm_qus_stroking_1_28, data = data)
## 
## Compare RSA_tog across bgm_qus_stroking_1_28 with levels 0 and 1 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  bgm_qus_stroking_1_28, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for bgm_qus_stroking_1_28 0:  n.miss = 10,  n = 97,  mean = 2.638931318,  sd = 1.018606879
## RSA_tog for bgm_qus_stroking_1_28 1:  n.miss = 5,  n = 7,  mean = 1.676709078,  sd = 0.774929582
## 
## Mean Difference of RSA_tog:  0.962222241
## Weighted Average Standard Deviation:   1.005908294 
## Standardized Mean Difference of RSA_tog: 0.956570540
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.983 
## Standard Error of Mean Difference: SE =  0.393677117 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 2.444,  df = 102,  p-value = 0.016
## 
## Margin of Error for 95% Confidence Level:  0.780856695
## 95% Confidence Interval for Mean Difference:  0.181365545 to 1.743078936

table(data$bgm_qus_talking_1_28)
## 
##   0   1 
## 108  11
lessR::tt_brief(RSA_tog  ~ bgm_qus_talking_1_28, data = data)
## 
## Compare RSA_tog across bgm_qus_talking_1_28 with levels 0 and 1 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  bgm_qus_talking_1_28, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for bgm_qus_talking_1_28 0:  n.miss = 14,  n = 94,  mean = 2.619762064,  sd = 1.038754729
## RSA_tog for bgm_qus_talking_1_28 1:  n.miss = 1,  n = 10,  mean = 2.145566740,  sd = 0.873897265
## 
## Mean Difference of RSA_tog:  0.474195324
## Weighted Average Standard Deviation:   1.025275318 
## Standardized Mean Difference of RSA_tog: 0.462505354
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.983 
## Standard Error of Mean Difference: SE =  0.341030519 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 1.390,  df = 102,  p-value = 0.167
## 
## Margin of Error for 95% Confidence Level:  0.676432417
## 95% Confidence Interval for Mean Difference:  -0.202237093 to 1.150627741

ANOVA(RSA_alone ~ fussiness_1_28, data)

## 
##   BACKGROUND 
## 
## Response Variable: RSA_alone 
##  
## Factor Variable: fussiness_1_28 
##   Levels: 1 2 3 
##  
## Number of cases (rows) of data:  142 
## Number of cases retained for analysis:  82 
## 
## 
##   DESCRIPTIVE STATISTICS  
## 
##     n         mean           sd          min          max 
## 1   4   2.44191578   1.40934657   1.44473560   4.51263513 
## 2  51   2.45518236   1.14651828   0.49254722   5.75527589 
## 3  27   2.90212801   1.30302229   0.42643528   5.17019126 
##  
## Grand Mean: 2.601700244 
## 
## 
##   ANOVA 
## 
##                      df        Sum Sq     Mean Sq     F-value   p-value 
## fussiness_1_28        2    3.63390099  1.81695050 1.23923782    0.2952 
## Residuals            79  115.82852571  1.46618387 
## 
## R Squared: 0.030 
## R Sq Adjusted: 0.016 
## Omega Squared: 0.006 
##  
## 
## Cohen's f: 0.076 
## 
## 
##   TUKEY MULTIPLE COMPARISONS OF MEANS 
## 
## Family-wise Confidence Level: 0.95 
## -------------------------------------------------- 
##             diff         lwr        upr      p adj 
##   2-1 0.01326658 -1.48855217 1.51508534 0.99975456 
##   3-1 0.46021223 -1.08939000 2.00981445 0.75866586 
##   3-2 0.44694565 -0.24143966 1.13533096 0.27306684 
## 
## 
##   RESIDUALS 
## 
## Fitted Values, Residuals, Standardized Residuals 
##    [sorted by Standardized Residuals, ignoring + or - sign] 
##    [res_rows = 20, out of 82 cases (rows) of data, or res_rows="all"] 
## -------------------------------------------------------------- 
##       fussiness_1_28 RSA_alone    fitted   residual    z-resid 
##    95              2 5.7552759 2.4551824  3.3000935  2.7525303 
##   123              2 5.0916757 2.4551824  2.6364934  2.1990371 
##   142              3 0.4264353 2.9021280 -2.4756927 -2.0835203 
##    10              1 4.5126351 2.4419158  2.0707193  1.9746785 
##     6              3 5.1701913 2.9021280  2.2680632  1.9087812 
##    32              3 5.1095165 2.9021280  2.2073885  1.8577179 
##    99              2 4.6399367 2.4551824  2.1847543  1.8222522 
##     8              2 4.6374029 2.4551824  2.1822205  1.8201388 
##    77              3 5.0627174 2.9021280  2.1605894  1.8183322 
##    29              3 0.7697158 2.9021280 -2.1324122 -1.7946185 
##    13              2 0.4925472 2.4551824 -1.9626351 -1.6369878 
##    44              3 1.1185077 2.9021280 -1.7836203 -1.5010785 
##    18              3 4.6050791 2.9021280  1.7029511  1.4331880 
##    91              2 0.8714660 2.4551824 -1.5837164 -1.3209405 
##   121              3 1.3439190 2.9021280 -1.5582090 -1.3113744 
##    87              2 4.0016286 2.4551824  1.5464462  1.2898544 
##    15              2 0.9248220 2.4551824 -1.5303603 -1.2764375 
##    82              2 0.9878737 2.4551824 -1.4673086 -1.2238476 
##    76              2 1.0075809 2.4551824 -1.4476015 -1.2074104 
##    38              2 1.0817164 2.4551824 -1.3734660 -1.1455757 
## 
## ---------------------------------------- 
## Plot 1: 95% family-wise confidence level 
## Plot 2: Scatterplot with Cell Means 
## ----------------------------------------
ANOVA(RSA_tog ~ fussiness_1_28, data)

## 
##   BACKGROUND 
## 
## Response Variable: RSA_tog 
##  
## Factor Variable: fussiness_1_28 
##   Levels: 1 2 3 
##  
## Number of cases (rows) of data:  142 
## Number of cases retained for analysis:  104 
## 
## 
##   DESCRIPTIVE STATISTICS  
## 
##     n          mean            sd           min           max 
## 1   5   2.915267020   1.495003611   1.291251789   4.516449215 
## 2  74   2.554255135   0.941502398   0.626715921   4.637900423 
## 3  25   2.564883452   1.207462709   0.089632828   4.568989290 
##  
## Grand Mean: 2.5741663597 
## 
## 
##   ANOVA 
## 
##                        df         Sum Sq      Mean Sq      F-value   p-value 
## fussiness_1_28          2    0.613240418  0.306620209 0.285056173    0.7526 
## Residuals             101  108.640485729  1.075648374 
## 
## R Squared: 0.006 
## R Sq Adjusted: -0.009 
## Omega Squared: -0.014 
## 
## 
##   TUKEY MULTIPLE COMPARISONS OF MEANS 
## 
## Family-wise Confidence Level: 0.95 
## ------------------------------------------------------- 
##               diff          lwr         upr       p adj 
##   2-1 -0.361011884 -1.500993608 0.778969839 0.732329001 
##   3-1 -0.350383568 -1.559006488 0.858239353 0.770090145 
##   3-2  0.010628317 -0.560083596 0.581340230 0.998918654 
## 
## 
##   RESIDUALS 
## 
## Fitted Values, Residuals, Standardized Residuals 
##    [sorted by Standardized Residuals, ignoring + or - sign] 
##    [res_rows = 20, out of 104 cases (rows) of data, or res_rows="all"] 
## ------------------------------------------------------------------ 
##       fussiness_1_28    RSA_tog     fitted    residual     z-resid 
##   142              3 0.08963283 2.56488345 -2.47525062 -2.43583799 
##   105              3 0.44957853 2.56488345 -2.11530492 -2.08162359 
##    56              2 4.63790042 2.55425514  2.08364529  2.02275394 
##     6              3 4.56898929 2.56488345  2.00410584  1.97219509 
##    30              2 4.58077739 2.55425514  2.02652225  1.96730024 
##    66              2 0.62671592 2.55425514 -1.92753921 -1.87120983 
##     4              2 0.73155758 2.55425514 -1.82269756 -1.76943201 
##    11              1 1.29125179 2.91526702 -1.62401523 -1.75069278 
##    10              1 4.51644921 2.91526702  1.60118220  1.72607871 
##   129              1 4.47634939 2.91526702  1.56108237  1.68285100 
##   111              3 4.26270743 2.56488345  1.69782397  1.67079006 
##    45              3 4.24219180 2.56488345  1.67730835  1.65060110 
##   121              3 0.94559980 2.56488345 -1.61928366 -1.59350031 
##    14              2 0.93297024 2.55425514 -1.62128489 -1.57390532 
##    74              2 4.09886252 2.55425514  1.54460738  1.49946859 
##    76              2 1.01887036 2.55425514 -1.53538478 -1.49051550 
##   123              2 4.04540144 2.55425514  1.49114631  1.44756983 
##    81              3 1.09421656 2.56488345 -1.47066690 -1.44724993 
##    75              2 1.12220879 2.55425514 -1.43204635 -1.39019698 
##   100              2 3.95197414 2.55425514  1.39771901  1.35687281 
## 
## ---------------------------------------- 
## Plot 1: 95% family-wise confidence level 
## Plot 2: Scatterplot with Cell Means 
## ----------------------------------------
completedat <- data %>% filter(!is.na(RSA_alone) & !is.na(RSA_tog)) 


data %>% 
  ggplot(aes(RSA_alone, RSA_tog)) +
  geom_point(size = 4, colour = "maroon")+
  geom_smooth(method = "lm", size = 1, color = "black", alpha = 0.2) + theme_modern() + 
  labs(
    x = "RSA Alone",
    y = "RSA with Mom"
  )
## `geom_smooth()` using formula = 'y ~ x'

RSA quality predictors

% of children with full baseline with mom % of children with partial baseline with mom % of children with full baseline alone % of children with partial baseline alone % of children with unusable data

## [1] 142 119
## Variable     | Level | n_Obs | percentage_Obs
## ---------------------------------------------
## bgc_a_b_comp |     0 |    59 |          41.55
## bgc_a_b_comp |     1 |    83 |          58.45
## bgc_a_b_par  |     0 |   135 |          95.07
## bgc_a_b_par  |     1 |     7 |           4.93
## bgc_a_b_un   |     0 |   136 |          95.77
## bgc_a_b_un   |     1 |     6 |           4.23
## bgc_a_b_nq   |     0 |   111 |          78.17
## bgc_a_b_nq   |     1 |    31 |          21.83
## bgc_a_b_na   |     0 |   130 |          91.55
## bgc_a_b_na   |     1 |    12 |           8.45
## Variable     | Level | n_Obs | percentage_Obs
## ---------------------------------------------
## bgm_t_b_comp |     0 |    37 |          26.06
## bgm_t_b_comp |     1 |   105 |          73.94
## bgm_t_b_par  |     0 |   125 |          88.03
## bgm_t_b_par  |     1 |    17 |          11.97
## bgm_t_b_un   |     0 |   130 |          91.55
## bgm_t_b_un   |     1 |    12 |           8.45
## bgm_t_b_nq   |     0 |   141 |          99.30
## bgm_t_b_nq   |     1 |     1 |           0.70
## bgm_t_b_na   |     0 |   136 |          95.77
## bgm_t_b_na   |     1 |     6 |           4.23
## Variable        |   Level | n_Obs | percentage_Obs
## --------------------------------------------------
## together_usable |       0 |    12 |           8.45
## together_usable |       1 |   122 |          85.92
## together_usable |      99 |     5 |           3.52
## together_usable | missing |     3 |           2.11
## alone_usable    |       0 |     6 |           4.23
## alone_usable    |       1 |    90 |          63.38
## alone_usable    |      99 |    12 |           8.45
## alone_usable    | missing |    34 |          23.94
## Variable          |   Level | n_Obs | percentage_Obs
## ----------------------------------------------------
## together_usable   |       0 |    12 |           8.51
## together_usable   |       1 |   122 |          86.52
## together_usable   |      99 |     5 |           3.55
## together_usable   | missing |     2 |           1.42
## together_usable_b |       0 |    17 |          12.06
## together_usable_b |       1 |   122 |          86.52
## together_usable_b | missing |     2 |           1.42
## Variable       |   Level | n_Obs | percentage_Obs
## -------------------------------------------------
## alone_usable   |       0 |     6 |           5.41
## alone_usable   |       1 |    90 |          81.08
## alone_usable   |      99 |    12 |          10.81
## alone_usable   | missing |     3 |           2.70
## alone_usable_b |       0 |    18 |          16.22
## alone_usable_b |       1 |    90 |          81.08
## alone_usable_b | missing |     3 |           2.70
## # A tibble: 3 × 2
##   `is.na(bgc_avg) & alone_usable == 99`     n
##   <lgl>                                 <int>
## 1 FALSE                                   125
## 2 TRUE                                      6
## 3 NA                                       11
## # A tibble: 2 × 2
##   `!is.na(RSA_tog) & !is.na(RSA_alone)`     n
##   <lgl>                                 <int>
## 1 FALSE                                    74
## 2 TRUE                                     68
## # A tibble: 2 × 2
##   `!is.na(RSA_tog) & is.na(RSA_alone)`     n
##   <lgl>                                <int>
## 1 FALSE                                  105
## 2 TRUE                                    37
## # A tibble: 2 × 2
##   `is.na(RSA_tog) & !is.na(RSA_alone)`     n
##   <lgl>                                <int>
## 1 FALSE                                  127
## 2 TRUE                                    15
## # A tibble: 142 × 2
##    hhid_int     n
##       <dbl> <int>
##  1       45     1
##  2      171     1
##  3      176     1
##  4      183     1
##  5      202     1
##  6      204     1
##  7      213     1
##  8      214     1
##  9      235     1
## 10      257     1
## # ℹ 132 more rows

## 
##   BACKGROUND 
## 
## Response Variable: bgc_avg 
##  
## Factor Variable: alone_usable 
##   Levels: 0 1 99 
##  
## Number of cases (rows) of data:  142 
## Number of cases retained for analysis:  94 
## 
## 
##   DESCRIPTIVE STATISTICS  
## 
##      n   mean     sd    min    max 
## 0    3   5.50   0.50   5.00   6.00 
## 1   85   3.76   1.57   1.00   6.00 
## 99   6   4.67   0.52   4.00   5.00 
##  
## Grand Mean: 3.878 
## 
## 
##   ANOVA 
## 
##                 df    Sum Sq   Mean Sq   F-value   p-value 
## alone_usable     2     12.72      6.36      2.76    0.0686 
## Residuals       91    209.63      2.30 
## 
## R Squared: 0.057 
## R Sq Adjusted: 0.044 
## Omega Squared: 0.036 
##  
## 
## Cohen's f: 0.194 
## 
## 
##   TUKEY MULTIPLE COMPARISONS OF MEANS 
## 
## Family-wise Confidence Level: 0.95 
## ----------------------------- 
##         diff   lwr  upr p adj 
##    1-0 -1.74 -3.86 0.39  0.13 
##   99-0 -0.83 -3.39 1.72  0.72 
##   99-1  0.90 -0.63 2.43  0.34 
## 
## 
##   RESIDUALS 
## 
## Fitted Values, Residuals, Standardized Residuals 
##    [sorted by Standardized Residuals, ignoring + or - sign] 
##    [res_rows = 20, out of 94 cases (rows) of data, or res_rows="all"] 
## -------------------------------------------------- 
##       alone_usable bgc_avg fitted residual z-resid 
##    10            1    1.00   3.76    -2.76   -1.83 
##    87            1    1.00   3.76    -2.76   -1.83 
##    90            1    1.00   3.76    -2.76   -1.83 
##    94            1    1.00   3.76    -2.76   -1.83 
##    99            1    1.00   3.76    -2.76   -1.83 
##   100            1    1.00   3.76    -2.76   -1.83 
##   109            1    1.00   3.76    -2.76   -1.83 
##   118            1    1.00   3.76    -2.76   -1.83 
##   125            1    1.00   3.76    -2.76   -1.83 
##    17            1    1.50   3.76    -2.26   -1.50 
##    43            1    1.50   3.76    -2.26   -1.50 
##   115            1    1.50   3.76    -2.26   -1.50 
##   123            1    1.50   3.76    -2.26   -1.50 
##     9            1    6.00   3.76     2.24    1.48 
##    13            1    6.00   3.76     2.24    1.48 
##    38            1    6.00   3.76     2.24    1.48 
##     6            1    6.00   3.76     2.24    1.48 
##     5            1    6.00   3.76     2.24    1.48 
##    32            1    2.00   3.76    -1.76   -1.17 
##    45            1    2.00   3.76    -1.76   -1.17 
## 
## ---------------------------------------- 
## Plot 1: 95% family-wise confidence level 
## Plot 2: Scatterplot with Cell Means 
## ----------------------------------------

## 
##   BACKGROUND 
## 
## Response Variable: bgm_avg 
##  
## Factor Variable: together_usable 
##   Levels: 0 1 99 
##  
## Number of cases (rows) of data:  142 
## Number of cases retained for analysis:  116 
## 
## 
##   DESCRIPTIVE STATISTICS  
## 
##       n   mean     sd    min    max 
## 0     5   4.70   0.84   4.00   6.00 
## 1   107   3.44   1.50   1.00   6.00 
## 99    4   5.00   2.00   2.00   6.00 
##  
## Grand Mean: 3.547 
## 
## 
##   ANOVA 
## 
##                    df    Sum Sq   Mean Sq   F-value   p-value 
## together_usable     2     16.33      8.17      3.64    0.0294 
## Residuals         113    253.66      2.24 
## 
## R Squared: 0.060 
## R Sq Adjusted: 0.047 
## Omega Squared: 0.044 
##  
## 
## Cohen's f: 0.213 
## 
## 
##   TUKEY MULTIPLE COMPARISONS OF MEANS 
## 
## Family-wise Confidence Level: 0.95 
## ----------------------------- 
##         diff   lwr  upr p adj 
##    1-0 -1.26 -2.89 0.37  0.16 
##   99-0  0.30 -2.09 2.69  0.95 
##   99-1  1.56 -0.25 3.37  0.11 
## 
## 
##   RESIDUALS 
## 
## Fitted Values, Residuals, Standardized Residuals 
##    [sorted by Standardized Residuals, ignoring + or - sign] 
##    [res_rows = 20, out of 116 cases (rows) of data, or res_rows="all"] 
## ----------------------------------------------------- 
##       together_usable bgm_avg fitted residual z-resid 
##    91              99    2.00   5.00    -3.00   -2.31 
##     6               1    6.00   3.44     2.56    1.72 
##     9               1    6.00   3.44     2.56    1.72 
##    16               1    6.00   3.44     2.56    1.72 
##    38               1    6.00   3.44     2.56    1.72 
##    17               1    1.00   3.44    -2.44   -1.64 
##    54               1    1.00   3.44    -2.44   -1.64 
##    74               1    1.00   3.44    -2.44   -1.64 
##    87               1    1.00   3.44    -2.44   -1.64 
##    90               1    1.00   3.44    -2.44   -1.64 
##    94               1    1.00   3.44    -2.44   -1.64 
##   100               1    1.00   3.44    -2.44   -1.64 
##   105               1    1.00   3.44    -2.44   -1.64 
##   109               1    1.00   3.44    -2.44   -1.64 
##   112               1    1.00   3.44    -2.44   -1.64 
##   118               1    1.00   3.44    -2.44   -1.64 
##   124               1    1.00   3.44    -2.44   -1.64 
##    27               1    5.50   3.44     2.06    1.38 
##    37               1    5.50   3.44     2.06    1.38 
##    60               1    5.50   3.44     2.06    1.38 
## 
## ---------------------------------------- 
## Plot 1: 95% family-wise confidence level 
## Plot 2: Scatterplot with Cell Means 
## ----------------------------------------
## 
## Compare bgc_avg across alone_usable_b with levels 0 and 1 
## Response Variable:  bgc_avg, bgc_avg
## Grouping Variable:  alone_usable_b, 
## 
## 
##  --- Describe ---
## 
## bgc_avg for alone_usable_b 0:  n.miss = 9,  n = 9,  mean = 4.944,  sd = 0.635
## bgc_avg for alone_usable_b 1:  n.miss = 5,  n = 85,  mean = 3.765,  sd = 1.573
## 
## Mean Difference of bgc_avg:  1.180
## Weighted Average Standard Deviation:   1.514 
## Standardized Mean Difference of bgc_avg: 0.779
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.986 
## Standard Error of Mean Difference: SE =  0.531 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 2.222,  df = 92,  p-value = 0.029
## 
## Margin of Error for 95% Confidence Level:  1.054
## 95% Confidence Interval for Mean Difference:  0.125 to 2.234

## 
## Compare bgm_avg across together_usable_b with levels 0 and 1 
## Response Variable:  bgm_avg, bgm_avg
## Grouping Variable:  together_usable_b, 
## 
## 
##  --- Describe ---
## 
## bgm_avg for together_usable_b 0:  n.miss = 8,  n = 9,  mean = 4.833,  sd = 1.369
## bgm_avg for together_usable_b 1:  n.miss = 15,  n = 107,  mean = 3.439,  sd = 1.501
## 
## Mean Difference of bgm_avg:  1.394
## Weighted Average Standard Deviation:   1.492 
## Standardized Mean Difference of bgm_avg: 0.934
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.981 
## Standard Error of Mean Difference: SE =  0.518 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 2.692,  df = 114,  p-value = 0.008
## 
## Margin of Error for 95% Confidence Level:  1.026
## 95% Confidence Interval for Mean Difference:  0.368 to 2.420

## 
## Compare bgc_avg across bgc_a_b_par with levels 1 and 0 
## Response Variable:  bgc_avg, bgc_avg
## Grouping Variable:  bgc_a_b_par, 
## 
## 
##  --- Describe ---
## 
## bgc_avg for bgc_a_b_par 1:  n.miss = 4,  n = 3,  mean = 4.167,  sd = 1.258
## bgc_avg for bgc_a_b_par 0:  n.miss = 13,  n = 91,  mean = 3.868,  sd = 1.560
## 
## Mean Difference of bgc_avg:  0.299
## Weighted Average Standard Deviation:   1.554 
## Standardized Mean Difference of bgc_avg: 0.192
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.986 
## Standard Error of Mean Difference: SE =  0.912 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.327,  df = 92,  p-value = 0.744
## 
## Margin of Error for 95% Confidence Level:  1.811
## 95% Confidence Interval for Mean Difference:  -1.512 to 2.109

## 
## Compare bgm_avg across date_category with levels October 2023 and January 2024 
## Response Variable:  bgm_avg, bgm_avg
## Grouping Variable:  date_category, 
## 
## 
##  --- Describe ---
## 
## bgm_avg for date_category October 2023:  n.miss = 10,  n = 45,  mean = 4.122,  sd = 1.474
## bgm_avg for date_category January 2024:  n.miss = 7,  n = 49,  mean = 3.224,  sd = 1.479
## 
## Mean Difference of bgm_avg:  0.898
## Weighted Average Standard Deviation:   1.477 
## Standardized Mean Difference of bgm_avg: 0.608
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.986 
## Standard Error of Mean Difference: SE =  0.305 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 2.944,  df = 92,  p-value = 0.004
## 
## Margin of Error for 95% Confidence Level:  0.606
## 95% Confidence Interval for Mean Difference:  0.292 to 1.503

## 
## Compare bgc_avg across date_category with levels October 2023 and January 2024 
## Response Variable:  bgc_avg, bgc_avg
## Grouping Variable:  date_category, 
## 
## 
##  --- Describe ---
## 
## bgc_avg for date_category October 2023:  n.miss = 13,  n = 59,  mean = 4.017,  sd = 1.600
## bgc_avg for date_category January 2024:  n.miss = 12,  n = 58,  mean = 3.362,  sd = 1.480
## 
## Mean Difference of bgc_avg:  0.655
## Weighted Average Standard Deviation:   1.542 
## Standardized Mean Difference of bgc_avg: 0.425
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.981 
## Standard Error of Mean Difference: SE =  0.285 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 2.297,  df = 115,  p-value = 0.023
## 
## Margin of Error for 95% Confidence Level:  0.565
## 95% Confidence Interval for Mean Difference:  0.090 to 1.220

## 
## Compare RSA_tog across date_category with levels January 2024 and October 2023 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  date_category, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for date_category January 2024:  n.miss = 16,  n = 54,  mean = 2.60273137,  sd = 1.02962524
## RSA_tog for date_category October 2023:  n.miss = 21,  n = 51,  mean = 2.56138744,  sd = 1.03738174
## 
## Mean Difference of RSA_tog:  0.04134393
## Weighted Average Standard Deviation:   1.03339780 
## Standardized Mean Difference of RSA_tog: 0.04000776
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.983 
## Standard Error of Mean Difference: SE =  0.20178097 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.205,  df = 103,  p-value = 0.838
## 
## Margin of Error for 95% Confidence Level:  0.40018497
## 95% Confidence Interval for Mean Difference:  -0.35884104 to 0.44152891

## 
## Compare RSA_alone across date_category with levels January 2024 and October 2023 
## Response Variable:  RSA_alone, RSA_alone
## Grouping Variable:  date_category, 
## 
## 
##  --- Describe ---
## 
## RSA_alone for date_category January 2024:  n.miss = 23,  n = 47,  mean = 2.69033837,  sd = 1.16762668
## RSA_alone for date_category October 2023:  n.miss = 36,  n = 36,  mean = 2.50385687,  sd = 1.26996722
## 
## Mean Difference of RSA_alone:  0.18648151
## Weighted Average Standard Deviation:   1.21290785 
## Standardized Mean Difference of RSA_alone: 0.15374746
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.990 
## Standard Error of Mean Difference: SE =  0.26863752 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.694,  df = 81,  p-value = 0.490
## 
## Margin of Error for 95% Confidence Level:  0.53450440
## 95% Confidence Interval for Mean Difference:  -0.34802290 to 0.72098591


    Pearson's Chi-squared test with Yates' continuity correction

data:  tab
X-squared = 1.0078, df = 1, p-value = 0.3154

    Pearson's Chi-squared test with Yates' continuity correction

data:  tab
X-squared = 0.0038317, df = 1, p-value = 0.9506

## >>> Suggestions
## Plot(together_usable_b, date_category)  # bubble plot
## BarChart(together_usable_b, by=date_category, horiz=TRUE)  # horizontal bar chart
## BarChart(together_usable_b, fill="steelblue")  # steelblue bars 
## 
## Joint and Marginal Frequencies 
## ------------------------------ 
##  
##  together_usable_b 
## date_category     0   1 Sum 
##   October 2023   11  59  70 
##   January 2024    6  63  69 
##   Sum            17 122 139 
## 
## Cramer's V (phi): 0.107 
##  
## Chi-square Test of Independence:
##      Chisq = 1.595, df = 1, p-value = 0.207 
## 
## Cell Proportions within Each Column 
## ----------------------------------- 
##  
##  together_usable_b 
## date_category         0       1 
##   October 2023    0.647   0.484 
##   January 2024    0.353   0.516 
##   Sum             1.000   1.000

## >>> Suggestions
## Plot(alone_usable_b, date_category)  # bubble plot
## BarChart(alone_usable_b, by=date_category, horiz=TRUE)  # horizontal bar chart
## BarChart(alone_usable_b, fill="steelblue")  # steelblue bars 
## 
## Joint and Marginal Frequencies 
## ------------------------------ 
##  
##     alone_usable_b 
## date_category     0   1 Sum 
##   October 2023   12  41  53 
##   January 2024    6  49  55 
##   Sum            18  90 108 
## 
## Cramer's V (phi): 0.157 
##  
## Chi-square Test of Independence:
##      Chisq = 2.675, df = 1, p-value = 0.102 
## 
## Cell Proportions within Each Column 
## ----------------------------------- 
##  
##     alone_usable_b 
## date_category         0       1 
##   October 2023    0.667   0.456 
##   January 2024    0.333   0.544 
##   Sum             1.000   1.000

## >>> Suggestions
## Plot(restype, together_usable_b)  # bubble plot
## BarChart(restype, by=together_usable_b, horiz=TRUE)  # horizontal bar chart
## BarChart(restype, fill="steelblue")  # steelblue bars 
## 
## Joint and Marginal Frequencies 
## ------------------------------ 
##  
##                restype 
## together_usable_b     1   2 Sum 
##   0                   8   1   9 
##   1                  85  25 110 
##   Sum                93  26 119 
## 
## Cramer's V (phi): 0.074 
##  
## Chi-square Test of Independence:
##      Chisq = 0.657, df = 1, p-value = 0.417 
## >>> Low cell expected frequencies, chi-squared approximation may not be accurate 
## 
## Cell Proportions within Each Column 
## ----------------------------------- 
##  
##                restype 
## together_usable_b         1       2 
##   0                   0.086   0.038 
##   1                   0.914   0.962 
##   Sum                 1.000   1.000

## >>> Suggestions
## Plot(restype, alone_usable_b)  # bubble plot
## BarChart(restype, by=alone_usable_b, horiz=TRUE)  # horizontal bar chart
## BarChart(restype, fill="steelblue")  # steelblue bars 
## 
## Joint and Marginal Frequencies 
## ------------------------------ 
##  
##             restype 
## alone_usable_b     1   2 Sum 
##   0                7   4  11 
##   1               70  16  86 
##   Sum             77  20  97 
## 
## Cramer's V (phi): 0.139 
##  
## Chi-square Test of Independence:
##      Chisq = 1.879, df = 1, p-value = 0.170 
## >>> Low cell expected frequencies, chi-squared approximation may not be accurate 
## 
## Cell Proportions within Each Column 
## ----------------------------------- 
##  
##             restype 
## alone_usable_b         1       2 
##   0                0.091   0.200 
##   1                0.909   0.800 
##   Sum              1.000   1.000
## 
##   0   1 
## 105  14

    Pearson's Chi-squared test with Yates' continuity correction

data:  tab
X-squared = 0.00000000000000000000000000000017756, df = 1, p-value = 1

## >>> Suggestions
## Plot(together_usable_b, bgm_qus_face_1_28)  # bubble plot
## BarChart(together_usable_b, by=bgm_qus_face_1_28, horiz=TRUE)  # horizontal bar chart
## BarChart(together_usable_b, fill="steelblue")  # steelblue bars 
## 
## Joint and Marginal Frequencies 
## ------------------------------ 
##  
##      together_usable_b 
## bgm_qus_face_1_28     0   1 Sum 
##   0                   8  96 104 
##   1                   1  13  14 
##   Sum                 9 109 118 
## 
## Cramer's V (phi): 0.007 
##  
## Chi-square Test of Independence:
##      Chisq = 0.005, df = 1, p-value = 0.942 
## >>> Low cell expected frequencies, chi-squared approximation may not be accurate

## >>> Suggestions
## Plot(alone_usable_b, bgm_qus_face_1_28)  # bubble plot
## BarChart(alone_usable_b, by=bgm_qus_face_1_28, horiz=TRUE)  # horizontal bar chart
## BarChart(alone_usable_b, fill="steelblue")  # steelblue bars 
## 
## Joint and Marginal Frequencies 
## ------------------------------ 
##  
##         alone_usable_b 
## bgm_qus_face_1_28     0   1 Sum 
##   0                   8  76  84 
##   1                   3   9  12 
##   Sum                11  85  96 
## 
## Cramer's V (phi): 0.161 
##  
## Chi-square Test of Independence:
##      Chisq = 2.479, df = 1, p-value = 0.115 
## >>> Low cell expected frequencies, chi-squared approximation may not be accurate 
## 
## Cell Proportions within Each Column 
## ----------------------------------- 
##  
##         alone_usable_b 
## bgm_qus_face_1_28         0       1 
##   0                   0.727   0.894 
##   1                   0.273   0.106 
##   Sum                 1.000   1.000
## 
##   0   1 
## 113   6

## >>> Suggestions
## Plot(together_usable_b, bgm_qus_bfeed_1_28)  # bubble plot
## BarChart(together_usable_b, by=bgm_qus_bfeed_1_28, horiz=TRUE)  # horizontal bar chart
## BarChart(together_usable_b, fill="steelblue")  # steelblue bars 
## 
## Joint and Marginal Frequencies 
## ------------------------------ 
##  
##       together_usable_b 
## bgm_qus_bfeed_1_28     0   1 Sum 
##   0                    9 103 112 
##   1                    0   6   6 
##   Sum                  9 109 118 
## 
## Cramer's V (phi): 0.067 
##  
## Chi-square Test of Independence:
##      Chisq = 0.522, df = 1, p-value = 0.470 
## >>> Low cell expected frequencies, chi-squared approximation may not be accurate 
## 
## Cell Proportions within Each Column 
## ----------------------------------- 
##  
##       together_usable_b 
## bgm_qus_bfeed_1_28         0       1 
##   0                    1.000   0.945 
##   1                    0.000   0.055 
##   Sum                  1.000   1.000

## >>> Suggestions
## Plot(alone_usable_b, bgm_qus_bfeed_1_28)  # bubble plot
## BarChart(alone_usable_b, by=bgm_qus_bfeed_1_28, horiz=TRUE)  # horizontal bar chart
## BarChart(alone_usable_b, fill="steelblue")  # steelblue bars 
## 
## Joint and Marginal Frequencies 
## ------------------------------ 
##  
##          alone_usable_b 
## bgm_qus_bfeed_1_28     0   1 Sum 
##   0                   11  79  90 
##   1                    0   6   6 
##   Sum                 11  85  96 
## 
## Cramer's V (phi): 0.093 
##  
## Chi-square Test of Independence:
##      Chisq = 0.828, df = 1, p-value = 0.363 
## >>> Low cell expected frequencies, chi-squared approximation may not be accurate 
## 
## Cell Proportions within Each Column 
## ----------------------------------- 
##  
##          alone_usable_b 
## bgm_qus_bfeed_1_28         0       1 
##   0                    1.000   0.929 
##   1                    0.000   0.071 
##   Sum                  1.000   1.000
## 
##  0  1 
## 57 62

## >>> Suggestions
## Plot(together_usable_b, bgm_qus_rocking_1_28)  # bubble plot
## BarChart(together_usable_b, by=bgm_qus_rocking_1_28, horiz=TRUE)  # horizontal bar chart
## BarChart(together_usable_b, fill="steelblue")  # steelblue bars 
## 
## Joint and Marginal Frequencies 
## ------------------------------ 
##  
##         together_usable_b 
## bgm_qus_rocking_1_28     0   1 Sum 
##   0                      2  55  57 
##   1                      7  54  61 
##   Sum                    9 109 118 
## 
## Cramer's V (phi): 0.150 
##  
## Chi-square Test of Independence:
##      Chisq = 2.654, df = 1, p-value = 0.103 
## >>> Low cell expected frequencies, chi-squared approximation may not be accurate 
## 
## Cell Proportions within Each Column 
## ----------------------------------- 
##  
##         together_usable_b 
## bgm_qus_rocking_1_28         0       1 
##   0                      0.222   0.505 
##   1                      0.778   0.495 
##   Sum                    1.000   1.000

## >>> Suggestions
## Plot(alone_usable_b, bgm_qus_rocking_1_28)  # bubble plot
## BarChart(alone_usable_b, by=bgm_qus_rocking_1_28, horiz=TRUE)  # horizontal bar chart
## BarChart(alone_usable_b, fill="steelblue")  # steelblue bars 
## 
## Joint and Marginal Frequencies 
## ------------------------------ 
##  
##            alone_usable_b 
## bgm_qus_rocking_1_28     0   1 Sum 
##   0                      4  42  46 
##   1                      7  43  50 
##   Sum                   11  85  96 
## 
## Cramer's V (phi): 0.083 
##  
## Chi-square Test of Independence:
##      Chisq = 0.664, df = 1, p-value = 0.415 
## 
## Cell Proportions within Each Column 
## ----------------------------------- 
##  
##            alone_usable_b 
## bgm_qus_rocking_1_28         0       1 
##   0                      0.364   0.494 
##   1                      0.636   0.506 
##   Sum                    1.000   1.000
## 
##   0   1 
## 107  12

## >>> Suggestions
## Plot(together_usable_b, bgm_qus_stroking_1_28)  # bubble plot
## BarChart(together_usable_b, by=bgm_qus_stroking_1_28, horiz=TRUE)  # horizontal bar chart
## BarChart(together_usable_b, fill="steelblue")  # steelblue bars 
## 
## Joint and Marginal Frequencies 
## ------------------------------ 
##  
##          together_usable_b 
## bgm_qus_stroking_1_28     0   1 Sum 
##   0                       7  99 106 
##   1                       2  10  12 
##   Sum                     9 109 118 
## 
## Cramer's V (phi): 0.115 
##  
## Chi-square Test of Independence:
##      Chisq = 1.549, df = 1, p-value = 0.213 
## >>> Low cell expected frequencies, chi-squared approximation may not be accurate 
## 
## Cell Proportions within Each Column 
## ----------------------------------- 
##  
##          together_usable_b 
## bgm_qus_stroking_1_28         0       1 
##   0                       0.778   0.908 
##   1                       0.222   0.092 
##   Sum                     1.000   1.000

## >>> Suggestions
## Plot(alone_usable_b, bgm_qus_stroking_1_28)  # bubble plot
## BarChart(alone_usable_b, by=bgm_qus_stroking_1_28, horiz=TRUE)  # horizontal bar chart
## BarChart(alone_usable_b, fill="steelblue")  # steelblue bars 
## 
## Joint and Marginal Frequencies 
## ------------------------------ 
##  
##             alone_usable_b 
## bgm_qus_stroking_1_28     0   1 Sum 
##   0                      10  75  85 
##   1                       1  10  11 
##   Sum                    11  85  96 
## 
## Cramer's V (phi): 0.027 
##  
## Chi-square Test of Independence:
##      Chisq = 0.069, df = 1, p-value = 0.793 
## >>> Low cell expected frequencies, chi-squared approximation may not be accurate 
## 
## Cell Proportions within Each Column 
## ----------------------------------- 
##  
##             alone_usable_b 
## bgm_qus_stroking_1_28         0       1 
##   0                       0.909   0.882 
##   1                       0.091   0.118 
##   Sum                     1.000   1.000
## 
##   0   1 
## 108  11

## >>> Suggestions
## Plot(together_usable_b, bgm_qus_talking_1_28)  # bubble plot
## BarChart(together_usable_b, by=bgm_qus_talking_1_28, horiz=TRUE)  # horizontal bar chart
## BarChart(together_usable_b, fill="steelblue")  # steelblue bars 
## 
## Joint and Marginal Frequencies 
## ------------------------------ 
##  
##         together_usable_b 
## bgm_qus_talking_1_28     0   1 Sum 
##   0                      8  99 107 
##   1                      1  10  11 
##   Sum                    9 109 118 
## 
## Cramer's V (phi): 0.018 
##  
## Chi-square Test of Independence:
##      Chisq = 0.037, df = 1, p-value = 0.848 
## >>> Low cell expected frequencies, chi-squared approximation may not be accurate 
## 
## Cell Proportions within Each Column 
## ----------------------------------- 
##  
##         together_usable_b 
## bgm_qus_talking_1_28         0       1 
##   0                      0.889   0.908 
##   1                      0.111   0.092 
##   Sum                    1.000   1.000

## >>> Suggestions
## Plot(alone_usable_b, bgm_qus_talking_1_28)  # bubble plot
## BarChart(alone_usable_b, by=bgm_qus_talking_1_28, horiz=TRUE)  # horizontal bar chart
## BarChart(alone_usable_b, fill="steelblue")  # steelblue bars 
## 
## Joint and Marginal Frequencies 
## ------------------------------ 
##  
##            alone_usable_b 
## bgm_qus_talking_1_28     0   1 Sum 
##   0                      9  79  88 
##   1                      2   6   8 
##   Sum                   11  85  96 
## 
## Cramer's V (phi): 0.128 
##  
## Chi-square Test of Independence:
##      Chisq = 1.577, df = 1, p-value = 0.209 
## >>> Low cell expected frequencies, chi-squared approximation may not be accurate 
## 
## Cell Proportions within Each Column 
## ----------------------------------- 
##  
##            alone_usable_b 
## bgm_qus_talking_1_28         0       1 
##   0                      0.818   0.929 
##   1                      0.182   0.071 
##   Sum                    1.000   1.000

Associations with baby variables RSA

# Child gender
lessR::tt_brief(RSA_tog  ~ child_gender_final, data = data)
## 
## Compare RSA_tog across child_gender_final with levels 1 and 2 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  child_gender_final, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for child_gender_final 1:  n.miss = 9,  n = 61,  mean = 2.585839827,  sd = 1.091141160
## RSA_tog for child_gender_final 2:  n.miss = 6,  n = 44,  mean = 2.578227819,  sd = 0.947491734
## 
## Mean Difference of RSA_tog:  0.007612008
## Weighted Average Standard Deviation:   1.033601429 
## Standardized Mean Difference of RSA_tog: 0.007364549
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.983 
## Standard Error of Mean Difference: SE =  0.204435586 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.037,  df = 103,  p-value = 0.970
## 
## Margin of Error for 95% Confidence Level:  0.405449767
## 95% Confidence Interval for Mean Difference:  -0.397837759 to 0.413061775

lessR::tt_brief(RSA_alone  ~ child_gender_final, data = data)
## 
## Compare RSA_alone across child_gender_final with levels 1 and 2 
## Response Variable:  RSA_alone, RSA_alone
## Grouping Variable:  child_gender_final, 
## 
## 
##  --- Describe ---
## 
## RSA_alone for child_gender_final 1:  n.miss = 23,  n = 47,  mean = 2.65577579,  sd = 1.24492147
## RSA_alone for child_gender_final 2:  n.miss = 14,  n = 36,  mean = 2.54898023,  sd = 1.17530588
## 
## Mean Difference of RSA_alone:  0.10679556
## Weighted Average Standard Deviation:   1.21533003 
## Standardized Mean Difference of RSA_alone: 0.08787371
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.990 
## Standard Error of Mean Difference: SE =  0.26917399 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.397,  df = 81,  p-value = 0.693
## 
## Margin of Error for 95% Confidence Level:  0.53557181
## 95% Confidence Interval for Mean Difference:  -0.42877625 to 0.64236737

# BIRTH --> NOTHING
table(data$underweight_birth)
## 
##  0  1 
## 98 10
lessR::tt_brief(RSA_tog  ~ underweight_birth, data = data)
## 
## Compare RSA_tog across underweight_birth with levels 1 and 0 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  underweight_birth, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for underweight_birth 1:  n.miss = 1,  n = 9,  mean = 2.56959139,  sd = 1.07481496
## RSA_tog for underweight_birth 0:  n.miss = 13,  n = 85,  mean = 2.55146442,  sd = 1.00555623
## 
## Mean Difference of RSA_tog:  0.01812697
## Weighted Average Standard Deviation:   1.01176695 
## Standardized Mean Difference of RSA_tog: 0.01791615
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.986 
## Standard Error of Mean Difference: SE =  0.35466122 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.051,  df = 92,  p-value = 0.959
## 
## Margin of Error for 95% Confidence Level:  0.70438779
## 95% Confidence Interval for Mean Difference:  -0.68626082 to 0.72251476

lessR::tt_brief(RSA_alone  ~ underweight_birth, data = data)
## 
## Compare RSA_alone across underweight_birth with levels 0 and 1 
## Response Variable:  RSA_alone, RSA_alone
## Grouping Variable:  underweight_birth, 
## 
## 
##  --- Describe ---
## 
## RSA_alone for underweight_birth 0:  n.miss = 34,  n = 64,  mean = 2.62959265,  sd = 1.14112460
## RSA_alone for underweight_birth 1:  n.miss = 2,  n = 8,  mean = 2.22102666,  sd = 1.70021967
## 
## Mean Difference of RSA_alone:  0.40856599
## Weighted Average Standard Deviation:   1.20872806 
## Standardized Mean Difference of RSA_alone: 0.33801316
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.994 
## Standard Error of Mean Difference: SE =  0.45327302 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.901,  df = 70,  p-value = 0.370
## 
## Margin of Error for 95% Confidence Level:  0.90402454
## 95% Confidence Interval for Mean Difference:  -0.49545854 to 1.31259053

table(data$weight_category_birth)
## 
##    Low Birth Weight Normal Birth Weight 
##                  15                  93
lessR::tt_brief(RSA_tog  ~ weight_category_birth, data = data)
## 
## Compare RSA_tog across weight_category_birth with levels Low Birth Weight and Normal Birth Weight 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  weight_category_birth, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for weight_category_birth Low Birth Weight:  n.miss = 2,  n = 13,  mean = 2.6496218,  sd = 0.9507491
## RSA_tog for weight_category_birth Normal Birth Weight:  n.miss = 12,  n = 81,  mean = 2.5377249,  sd = 1.0197621
## 
## Mean Difference of RSA_tog:  0.1118970
## Weighted Average Standard Deviation:   1.0110276 
## Standardized Mean Difference of RSA_tog: 0.1106765
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.986 
## Standard Error of Mean Difference: SE =  0.3020736 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.370,  df = 92,  p-value = 0.712
## 
## Margin of Error for 95% Confidence Level:  0.5999442
## 95% Confidence Interval for Mean Difference:  -0.4880473 to 0.7118412

lessR::tt_brief(RSA_alone  ~ weight_category_birth, data = data)
## 
## Compare RSA_alone across weight_category_birth with levels Normal Birth Weight and Low Birth Weight 
## Response Variable:  RSA_alone, RSA_alone
## Grouping Variable:  weight_category_birth, 
## 
## 
##  --- Describe ---
## 
## RSA_alone for weight_category_birth Normal Birth Weight:  n.miss = 31,  n = 62,  mean = 2.62419412,  sd = 1.15558659
## RSA_alone for weight_category_birth Low Birth Weight:  n.miss = 5,  n = 10,  mean = 2.33621079,  sd = 1.53790322
## 
## Mean Difference of RSA_alone:  0.28798333
## Weighted Average Standard Deviation:   1.21151923 
## Standardized Mean Difference of RSA_alone: 0.23770430
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.994 
## Standard Error of Mean Difference: SE =  0.41285801 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.698,  df = 70,  p-value = 0.488
## 
## Margin of Error for 95% Confidence Level:  0.82341934
## 95% Confidence Interval for Mean Difference:  -0.53543601 to 1.11140267

table(data$wasting_birth)
## 
##  0  1 
## 93 12
lessR::tt_brief(RSA_tog  ~ wasting_birth, data = data)
## 
## Compare RSA_tog across wasting_birth with levels 1 and 0 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  wasting_birth, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for wasting_birth 1:  n.miss = 3,  n = 9,  mean = 3.11476901,  sd = 1.01332659
## RSA_tog for wasting_birth 0:  n.miss = 11,  n = 82,  mean = 2.52319494,  sd = 0.99450551
## 
## Mean Difference of RSA_tog:  0.59157408
## Weighted Average Standard Deviation:   0.99621183 
## Standardized Mean Difference of RSA_tog: 0.59382358
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.987 
## Standard Error of Mean Difference: SE =  0.34981966 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 1.691,  df = 89,  p-value = 0.094
## 
## Margin of Error for 95% Confidence Level:  0.69508421
## 95% Confidence Interval for Mean Difference:  -0.10351013 to 1.28665828

lessR::tt_brief(RSA_alone  ~ wasting_birth, data = data)
## 
## Compare RSA_alone across wasting_birth with levels 1 and 0 
## Response Variable:  RSA_alone, RSA_alone
## Grouping Variable:  wasting_birth, 
## 
## 
##  --- Describe ---
## 
## RSA_alone for wasting_birth 1:  n.miss = 3,  n = 9,  mean = 2.81382973,  sd = 1.55988891
## RSA_alone for wasting_birth 0:  n.miss = 33,  n = 60,  mean = 2.57464909,  sd = 1.16286986
## 
## Mean Difference of RSA_alone:  0.23918064
## Weighted Average Standard Deviation:   1.21710287 
## Standardized Mean Difference of RSA_alone: 0.19651638
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.996 
## Standard Error of Mean Difference: SE =  0.43506581 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.550,  df = 67,  p-value = 0.584
## 
## Margin of Error for 95% Confidence Level:  0.86839498
## 95% Confidence Interval for Mean Difference:  -0.62921434 to 1.10757563

table(data$stunting_birth)
## 
##   0   1 
## 102   5
lessR::tt_brief(RSA_tog  ~ stunting_birth, data = data)
## 
## Compare RSA_tog across stunting_birth with levels 0 and 1 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  stunting_birth, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for stunting_birth 0:  n.miss = 13,  n = 89,  mean = 2.55843558,  sd = 1.02419738
## RSA_tog for stunting_birth 1:  n.miss = 1,  n = 4,  mean = 2.48299826,  sd = 0.77756667
## 
## Mean Difference of RSA_tog:  0.07543732
## Weighted Average Standard Deviation:   1.01702051 
## Standardized Mean Difference of RSA_tog: 0.07417483
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.986 
## Standard Error of Mean Difference: SE =  0.51981186 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.145,  df = 91,  p-value = 0.885
## 
## Margin of Error for 95% Confidence Level:  1.03254241
## 95% Confidence Interval for Mean Difference:  -0.95710509 to 1.10797972

lessR::tt_brief(RSA_alone  ~ stunting_birth, data = data)
## 
## Compare RSA_alone across stunting_birth with levels 0 and 1 
## Response Variable:  RSA_alone, RSA_alone
## Grouping Variable:  stunting_birth, 
## 
## 
##  --- Describe ---
## 
## RSA_alone for stunting_birth 0:  n.miss = 34,  n = 68,  mean = 2.58650841,  sd = 1.15766460
## RSA_alone for stunting_birth 1:  n.miss = 2,  n = 3,  mean = 2.24019048,  sd = 2.50454197
## 
## Mean Difference of RSA_alone:  0.34631793
## Weighted Average Standard Deviation:   1.21785040 
## Standardized Mean Difference of RSA_alone: 0.28436820
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.995 
## Standard Error of Mean Difference: SE =  0.71846900 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.482,  df = 69,  p-value = 0.631
## 
## Margin of Error for 95% Confidence Level:  1.43330643
## 95% Confidence Interval for Mean Difference:  -1.08698850 to 1.77962436

table(data$less_than_full_term)
## 
##  0  1 
## 81 39
lessR::tt_brief(RSA_tog  ~ less_than_full_term, data = data)
## 
## Compare RSA_tog across less_than_full_term with levels 0 and 1 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  less_than_full_term, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for less_than_full_term 0:  n.miss = 11,  n = 70,  mean = 2.63818571,  sd = 1.04981075
## RSA_tog for less_than_full_term 1:  n.miss = 4,  n = 35,  mean = 2.47157869,  sd = 0.99034907
## 
## Mean Difference of RSA_tog:  0.16660702
## Weighted Average Standard Deviation:   1.03056203 
## Standardized Mean Difference of RSA_tog: 0.16166617
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.983 
## Standard Error of Mean Difference: SE =  0.21334661 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.781,  df = 103,  p-value = 0.437
## 
## Margin of Error for 95% Confidence Level:  0.42312268
## 95% Confidence Interval for Mean Difference:  -0.25651566 to 0.58972970

lessR::tt_brief(RSA_alone  ~ less_than_full_term, data = data)
## 
## Compare RSA_alone across less_than_full_term with levels 0 and 1 
## Response Variable:  RSA_alone, RSA_alone
## Grouping Variable:  less_than_full_term, 
## 
## 
##  --- Describe ---
## 
## RSA_alone for less_than_full_term 0:  n.miss = 27,  n = 54,  mean = 2.61834432,  sd = 1.09151189
## RSA_alone for less_than_full_term 1:  n.miss = 10,  n = 29,  mean = 2.59290197,  sd = 1.42321790
## 
## Mean Difference of RSA_alone:  0.02544235
## Weighted Average Standard Deviation:   1.21644840 
## Standardized Mean Difference of RSA_alone: 0.02091527
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.990 
## Standard Error of Mean Difference: SE =  0.28005083 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.091,  df = 81,  p-value = 0.928
## 
## Margin of Error for 95% Confidence Level:  0.55721330
## 95% Confidence Interval for Mean Difference:  -0.53177094 to 0.58265565

# 28 DAYS --> NOTHING
table(data$underweight_28)
## 
##   0   1 
## 102  17
lessR::tt_brief(RSA_tog  ~ underweight_28, data = data)
## 
## Compare RSA_tog across underweight_28 with levels 1 and 0 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  underweight_28, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for underweight_28 1:  n.miss = 1,  n = 16,  mean = 2.812492160,  sd = 0.805595271
## RSA_tog for underweight_28 0:  n.miss = 14,  n = 88,  mean = 2.530834396,  sd = 1.063743925
## 
## Mean Difference of RSA_tog:  0.281657763
## Weighted Average Standard Deviation:   1.029847243 
## Standardized Mean Difference of RSA_tog: 0.273494701
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.983 
## Standard Error of Mean Difference: SE =  0.279890497 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 1.006,  df = 102,  p-value = 0.317
## 
## Margin of Error for 95% Confidence Level:  0.555161473
## 95% Confidence Interval for Mean Difference:  -0.273503710 to 0.836819237

lessR::tt_brief(RSA_alone  ~ underweight_28, data = data)
## 
## Compare RSA_alone across underweight_28 with levels 1 and 0 
## Response Variable:  RSA_alone, RSA_alone
## Grouping Variable:  underweight_28, 
## 
## 
##  --- Describe ---
## 
## RSA_alone for underweight_28 1:  n.miss = 4,  n = 13,  mean = 3.08836706,  sd = 1.51653899
## RSA_alone for underweight_28 0:  n.miss = 33,  n = 69,  mean = 2.51000939,  sd = 1.13891501
## 
## Mean Difference of RSA_alone:  0.57835767
## Weighted Average Standard Deviation:   1.20313834 
## Standardized Mean Difference of RSA_alone: 0.48070754
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.990 
## Standard Error of Mean Difference: SE =  0.36376949 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 1.590,  df = 80,  p-value = 0.116
## 
## Margin of Error for 95% Confidence Level:  0.72392436
## 95% Confidence Interval for Mean Difference:  -0.14556669 to 1.30228202

table(data$wasting_28)
## 
##  0  1 
## 99 20
lessR::tt_brief(RSA_tog  ~ wasting_28, data = data)
## 
## Compare RSA_tog across wasting_28 with levels 0 and 1 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  wasting_28, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for wasting_28 0:  n.miss = 15,  n = 84,  mean = 2.57807037,  sd = 1.02098443
## RSA_tog for wasting_28 1:  n.miss = 0,  n = 20,  mean = 2.55776951,  sd = 1.09369256
## 
## Mean Difference of RSA_tog:  0.02030086
## Weighted Average Standard Deviation:   1.03491531 
## Standardized Mean Difference of RSA_tog: 0.01961597
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.983 
## Standard Error of Mean Difference: SE =  0.25749384 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.079,  df = 102,  p-value = 0.937
## 
## Margin of Error for 95% Confidence Level:  0.51073781
## 95% Confidence Interval for Mean Difference:  -0.49043694 to 0.53103867

lessR::tt_brief(RSA_alone  ~ wasting_28, data = data)
## 
## Compare RSA_alone across wasting_28 with levels 1 and 0 
## Response Variable:  RSA_alone, RSA_alone
## Grouping Variable:  wasting_28, 
## 
## 
##  --- Describe ---
## 
## RSA_alone for wasting_28 1:  n.miss = 6,  n = 14,  mean = 2.66541450,  sd = 1.44411594
## RSA_alone for wasting_28 0:  n.miss = 31,  n = 68,  mean = 2.58858260,  sd = 1.17360760
## 
## Mean Difference of RSA_alone:  0.07683189
## Weighted Average Standard Deviation:   1.22164793 
## Standardized Mean Difference of RSA_alone: 0.06289201
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.990 
## Standard Error of Mean Difference: SE =  0.35853744 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.214,  df = 80,  p-value = 0.831
## 
## Margin of Error for 95% Confidence Level:  0.71351225
## 95% Confidence Interval for Mean Difference:  -0.63668035 to 0.79034414

table(data$stunting_28)
## 
##   0   1 
## 112   7
lessR::tt_brief(RSA_tog  ~ stunting_28, data = data)
## 
## Compare RSA_tog across stunting_28 with levels 0 and 1 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  stunting_28, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for stunting_28 0:  n.miss = 15,  n = 97,  mean = 2.584494538,  sd = 1.037451582
## RSA_tog for stunting_28 1:  n.miss = 0,  n = 7,  mean = 2.431047311,  sd = 0.981040457
## 
## Mean Difference of RSA_tog:  0.153447227
## Weighted Average Standard Deviation:   1.034218458 
## Standardized Mean Difference of RSA_tog: 0.148370227
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.983 
## Standard Error of Mean Difference: SE =  0.404756719 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.379,  df = 102,  p-value = 0.705
## 
## Margin of Error for 95% Confidence Level:  0.802833034
## 95% Confidence Interval for Mean Difference:  -0.649385806 to 0.956280261

#lessR::tt_brief(RSA_alone  ~ stunting_28, data = data)

table(data$less_than_full_term)
## 
##  0  1 
## 81 39
lessR::tt_brief(RSA_tog  ~ less_than_full_term, data = data)
## 
## Compare RSA_tog across less_than_full_term with levels 0 and 1 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  less_than_full_term, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for less_than_full_term 0:  n.miss = 11,  n = 70,  mean = 2.63818571,  sd = 1.04981075
## RSA_tog for less_than_full_term 1:  n.miss = 4,  n = 35,  mean = 2.47157869,  sd = 0.99034907
## 
## Mean Difference of RSA_tog:  0.16660702
## Weighted Average Standard Deviation:   1.03056203 
## Standardized Mean Difference of RSA_tog: 0.16166617
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.983 
## Standard Error of Mean Difference: SE =  0.21334661 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.781,  df = 103,  p-value = 0.437
## 
## Margin of Error for 95% Confidence Level:  0.42312268
## 95% Confidence Interval for Mean Difference:  -0.25651566 to 0.58972970

lessR::tt_brief(RSA_alone  ~ less_than_full_term, data = data)
## 
## Compare RSA_alone across less_than_full_term with levels 0 and 1 
## Response Variable:  RSA_alone, RSA_alone
## Grouping Variable:  less_than_full_term, 
## 
## 
##  --- Describe ---
## 
## RSA_alone for less_than_full_term 0:  n.miss = 27,  n = 54,  mean = 2.61834432,  sd = 1.09151189
## RSA_alone for less_than_full_term 1:  n.miss = 10,  n = 29,  mean = 2.59290197,  sd = 1.42321790
## 
## Mean Difference of RSA_alone:  0.02544235
## Weighted Average Standard Deviation:   1.21644840 
## Standardized Mean Difference of RSA_alone: 0.02091527
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.990 
## Standard Error of Mean Difference: SE =  0.28005083 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.091,  df = 81,  p-value = 0.928
## 
## Margin of Error for 95% Confidence Level:  0.55721330
## 95% Confidence Interval for Mean Difference:  -0.53177094 to 0.58265565

lessR::tt_brief(RSA_tog  ~ restype, data = data)
## 
## Compare RSA_tog across restype with levels 2 and 1 
## Response Variable:  RSA_tog, RSA_tog
## Grouping Variable:  restype, 
## 
## 
##  --- Describe ---
## 
## RSA_tog for restype 2:  n.miss = 1,  n = 25,  mean = 2.714849218,  sd = 0.884491427
## RSA_tog for restype 1:  n.miss = 14,  n = 80,  mean = 2.541337788,  sd = 1.071438253
## 
## Mean Difference of RSA_tog:  0.173511430
## Weighted Average Standard Deviation:   1.030911636 
## Standardized Mean Difference of RSA_tog: 0.168308732
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.983 
## Standard Error of Mean Difference: SE =  0.236211530 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.735,  df = 103,  p-value = 0.464
## 
## Margin of Error for 95% Confidence Level:  0.468469859
## 95% Confidence Interval for Mean Difference:  -0.294958429 to 0.641981289

lessR::tt_brief(RSA_alone  ~ restype, data = data)
## 
## Compare RSA_alone across restype with levels 2 and 1 
## Response Variable:  RSA_alone, RSA_alone
## Grouping Variable:  restype, 
## 
## 
##  --- Describe ---
## 
## RSA_alone for restype 2:  n.miss = 12,  n = 14,  mean = 2.83633301,  sd = 0.94133750
## RSA_alone for restype 1:  n.miss = 25,  n = 69,  mean = 2.56342157,  sd = 1.25724569
## 
## Mean Difference of RSA_alone:  0.27291143
## Weighted Average Standard Deviation:   1.21210382 
## Standardized Mean Difference of RSA_alone: 0.22515516
## 
##  --- Infer ---
## 
## t-cutoff for 95% range of variation: tcut =  1.990 
## Standard Error of Mean Difference: SE =  0.35529599 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.768,  df = 81,  p-value = 0.445
## 
## Margin of Error for 95% Confidence Level:  0.70692757
## 95% Confidence Interval for Mean Difference:  -0.43401613 to 0.97983900

####### ZSCORES
data %>%  correlation(p_adjust = "none", select = c("RSA_alone", "RSA_tog"), select2 = c( "child_age_final", "child_ga_final","wflz_28"  , "wfaz_28" ,"lfaz_28"   , "hcaz_28"   ,    "wflz_birth", "wfaz_birth" ,           "lfaz_birth" ,"hcaz_birth", "average_birth_muac" ,"average_baby_muac.y"), method = "pearson")
## # Correlation Matrix (pearson-method)
## 
## Parameter1 |          Parameter2 |         r |         95% CI |         t |  df |      p
## ----------------------------------------------------------------------------------------
## RSA_alone  |     child_age_final |      0.08 | [-0.14,  0.29] |      0.72 |  81 | 0.471 
## RSA_alone  |      child_ga_final |     -0.03 | [-0.25,  0.19] |     -0.26 |  80 | 0.792 
## RSA_alone  |             wflz_28 |      0.05 | [-0.17,  0.26] |      0.43 |  80 | 0.666 
## RSA_alone  |             wfaz_28 |     -0.08 | [-0.29,  0.14] |     -0.70 |  80 | 0.486 
## RSA_alone  |             lfaz_28 |     -0.13 | [-0.34,  0.09] |     -1.15 |  80 | 0.254 
## RSA_alone  |             hcaz_28 |     -0.10 | [-0.31,  0.12] |     -0.93 |  80 | 0.357 
## RSA_alone  |          wflz_birth |  7.37e-03 | [-0.23,  0.24] |      0.06 |  67 | 0.952 
## RSA_alone  |          wfaz_birth |      0.05 | [-0.18,  0.28] |      0.45 |  70 | 0.651 
## RSA_alone  |          lfaz_birth |     -0.02 | [-0.25,  0.21] |     -0.18 |  69 | 0.857 
## RSA_alone  |          hcaz_birth |      0.07 | [-0.17,  0.29] |      0.55 |  70 | 0.587 
## RSA_alone  |  average_birth_muac |      0.16 | [-0.08,  0.38] |      1.35 |  70 | 0.181 
## RSA_alone  | average_baby_muac.y |  2.79e-03 | [-0.21,  0.22] |      0.02 |  80 | 0.980 
## RSA_tog    |     child_age_final |      0.04 | [-0.16,  0.23] |      0.38 | 103 | 0.702 
## RSA_tog    |      child_ga_final |      0.07 | [-0.13,  0.25] |      0.67 | 103 | 0.502 
## RSA_tog    |             wflz_28 |     -0.08 | [-0.27,  0.11] |     -0.83 | 102 | 0.406 
## RSA_tog    |             wfaz_28 |     -0.08 | [-0.27,  0.11] |     -0.83 | 102 | 0.409 
## RSA_tog    |             lfaz_28 |     -0.02 | [-0.21,  0.18] |     -0.16 | 102 | 0.873 
## RSA_tog    |             hcaz_28 |     -0.22 | [-0.39, -0.03] |     -2.24 | 102 | 0.027*
## RSA_tog    |          wflz_birth |     -0.04 | [-0.25,  0.17] |     -0.39 |  89 | 0.698 
## RSA_tog    |          wfaz_birth | -3.34e-04 | [-0.20,  0.20] | -3.20e-03 |  92 | 0.997 
## RSA_tog    |          lfaz_birth |     -0.06 | [-0.26,  0.15] |     -0.54 |  91 | 0.593 
## RSA_tog    |          hcaz_birth |     -0.10 | [-0.29,  0.11] |     -0.92 |  92 | 0.359 
## RSA_tog    |  average_birth_muac |      0.09 | [-0.12,  0.29] |      0.85 |  92 | 0.397 
## RSA_tog    | average_baby_muac.y |     -0.03 | [-0.23,  0.16] |     -0.35 | 102 | 0.725 
## 
## p-value adjustment method: none
## Observations: 69-105
data %>%  filter(bgc_avg > 3) %>% correlation(p_adjust = "none", select = c("RSA_alone", "RSA_tog"), select2 = c( "child_age_final","child_ga_final","wflz_28"  , "wfaz_28" ,"lfaz_28"   ,        "hcaz_28"   ,    "wflz_birth", "wfaz_birth" ,           "lfaz_birth" ,"hcaz_birth", "average_birth_muac" ,"average_baby_muac.y"), method = "pearson")
## # Correlation Matrix (pearson-method)
## 
## Parameter1 |          Parameter2 |         r |        95% CI |         t | df |       p
## ---------------------------------------------------------------------------------------
## RSA_alone  |     child_age_final |      0.07 | [-0.21, 0.34] |      0.50 | 50 | 0.622  
## RSA_alone  |      child_ga_final |      0.06 | [-0.21, 0.33] |      0.46 | 50 | 0.650  
## RSA_alone  |             wflz_28 |  3.32e-03 | [-0.27, 0.28] |      0.02 | 50 | 0.981  
## RSA_alone  |             wfaz_28 |     -0.06 | [-0.33, 0.22] |     -0.41 | 50 | 0.685  
## RSA_alone  |             lfaz_28 |     -0.07 | [-0.34, 0.21] |     -0.49 | 50 | 0.624  
## RSA_alone  |             hcaz_28 | -9.74e-04 | [-0.27, 0.27] | -6.89e-03 | 50 | 0.995  
## RSA_alone  |          wflz_birth |      0.42 | [ 0.13, 0.65] |      2.91 | 39 | 0.006**
## RSA_alone  |          wfaz_birth |      0.33 | [ 0.04, 0.57] |      2.28 | 42 | 0.028* 
## RSA_alone  |          lfaz_birth |      0.07 | [-0.24, 0.36] |      0.43 | 41 | 0.671  
## RSA_alone  |          hcaz_birth |      0.15 | [-0.15, 0.43] |      1.01 | 42 | 0.316  
## RSA_alone  |  average_birth_muac |      0.32 | [ 0.02, 0.56] |      2.18 | 42 | 0.035* 
## RSA_alone  | average_baby_muac.y |      0.04 | [-0.24, 0.31] |      0.26 | 50 | 0.799  
## RSA_tog    |     child_age_final |      0.02 | [-0.24, 0.27] |      0.14 | 57 | 0.886  
## RSA_tog    |      child_ga_final |      0.09 | [-0.17, 0.34] |      0.67 | 57 | 0.504  
## RSA_tog    |             wflz_28 | -9.48e-03 | [-0.26, 0.25] |     -0.07 | 57 | 0.943  
## RSA_tog    |             wfaz_28 |     -0.06 | [-0.31, 0.20] |     -0.48 | 57 | 0.636  
## RSA_tog    |             lfaz_28 |     -0.05 | [-0.30, 0.21] |     -0.39 | 57 | 0.699  
## RSA_tog    |             hcaz_28 |     -0.11 | [-0.36, 0.15] |     -0.83 | 57 | 0.409  
## RSA_tog    |          wflz_birth |      0.16 | [-0.13, 0.43] |      1.08 | 45 | 0.285  
## RSA_tog    |          wfaz_birth |      0.11 | [-0.17, 0.38] |      0.79 | 48 | 0.432  
## RSA_tog    |          lfaz_birth |     -0.09 | [-0.36, 0.19] |     -0.64 | 47 | 0.528  
## RSA_tog    |          hcaz_birth |     -0.08 | [-0.35, 0.21] |     -0.54 | 48 | 0.594  
## RSA_tog    |  average_birth_muac |      0.16 | [-0.13, 0.42] |      1.10 | 48 | 0.278  
## RSA_tog    | average_baby_muac.y |      0.04 | [-0.21, 0.30] |      0.33 | 57 | 0.741  
## 
## p-value adjustment method: none
## Observations: 41-59
data %>% filter(bgc_avg <4)  %>% correlation(p_adjust = "none", select = c("RSA_alone", "RSA_tog"), select2 = c( "child_age_final","child_ga_final","wflz_28"  , "wfaz_28" ,"lfaz_28"   ,        "hcaz_28"   ,    "wflz_birth", "wfaz_birth" ,           "lfaz_birth" ,"hcaz_birth", "average_birth_muac" ,"average_baby_muac.y"), method = "pearson")
## # Correlation Matrix (pearson-method)
## 
## Parameter1 |          Parameter2 |        r |         95% CI |        t | df |      p
## -------------------------------------------------------------------------------------
## RSA_alone  |     child_age_final |     0.36 | [ 0.02,  0.63] |     2.18 | 31 | 0.037*
## RSA_alone  |      child_ga_final |    -0.28 | [-0.57,  0.07] |    -1.61 | 30 | 0.117 
## RSA_alone  |             wflz_28 |     0.04 | [-0.31,  0.38] |     0.23 | 31 | 0.823 
## RSA_alone  |             wfaz_28 |    -0.18 | [-0.50,  0.17] |    -1.04 | 31 | 0.307 
## RSA_alone  |             lfaz_28 |    -0.22 | [-0.52,  0.13] |    -1.26 | 31 | 0.216 
## RSA_alone  |             hcaz_28 |    -0.21 | [-0.52,  0.14] |    -1.19 | 31 | 0.242 
## RSA_alone  |          wflz_birth |    -0.38 | [-0.65, -0.01] |    -2.11 | 27 | 0.044*
## RSA_alone  |          wfaz_birth |    -0.32 | [-0.61,  0.06] |    -1.73 | 27 | 0.095 
## RSA_alone  |          lfaz_birth |    -0.10 | [-0.45,  0.28] |    -0.50 | 27 | 0.621 
## RSA_alone  |          hcaz_birth | 1.06e-03 | [-0.37,  0.37] | 5.49e-03 | 27 | 0.996 
## RSA_alone  |  average_birth_muac |    -0.04 | [-0.40,  0.33] |    -0.23 | 27 | 0.818 
## RSA_alone  | average_baby_muac.y |    -0.07 | [-0.41,  0.28] |    -0.42 | 31 | 0.680 
## RSA_tog    |     child_age_final |     0.22 | [-0.07,  0.48] |     1.50 | 44 | 0.140 
## RSA_tog    |      child_ga_final |     0.02 | [-0.27,  0.31] |     0.13 | 44 | 0.899 
## RSA_tog    |             wflz_28 |    -0.17 | [-0.44,  0.13] |    -1.14 | 44 | 0.259 
## RSA_tog    |             wfaz_28 |    -0.18 | [-0.44,  0.12] |    -1.19 | 44 | 0.239 
## RSA_tog    |             lfaz_28 |    -0.06 | [-0.35,  0.23] |    -0.42 | 44 | 0.673 
## RSA_tog    |             hcaz_28 |    -0.28 | [-0.53,  0.01] |    -1.92 | 44 | 0.061 
## RSA_tog    |          wflz_birth |    -0.16 | [-0.44,  0.14] |    -1.06 | 41 | 0.297 
## RSA_tog    |          wfaz_birth |    -0.15 | [-0.43,  0.16] |    -0.98 | 41 | 0.333 
## RSA_tog    |          lfaz_birth |    -0.08 | [-0.37,  0.23] |    -0.51 | 41 | 0.615 
## RSA_tog    |          hcaz_birth |    -0.06 | [-0.35,  0.25] |    -0.37 | 41 | 0.716 
## RSA_tog    |  average_birth_muac |    -0.02 | [-0.32,  0.28] |    -0.11 | 41 | 0.912 
## RSA_tog    | average_baby_muac.y |    -0.14 | [-0.42,  0.15] |    -0.96 | 44 | 0.344 
## 
## p-value adjustment method: none
## Observations: 29-46
######

s <- lm(RSA_alone ~ bgc_avg*wflz_birth + wflz_28 + child_ga_final + primiparous + child_age_final, data = data)
summary(s)
## 
## Call:
## lm(formula = RSA_alone ~ bgc_avg * wflz_birth + wflz_28 + child_ga_final + 
##     primiparous + child_age_final, data = data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.07342 -0.72472 -0.07827  0.69814  2.49853 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 5.2569916  5.0950878   1.032 0.306388    
## bgc_avg                     0.0370627  0.1191189   0.311 0.756790    
## wflz_birth                 -0.8124416  0.2600956  -3.124 0.002768 ** 
## wflz_28                    -0.0900779  0.1296987  -0.695 0.490084    
## child_ga_final             -0.0724659  0.1259341  -0.575 0.567191    
## primiparousNon-primiparous  0.2544618  0.2892039   0.880 0.382500    
## child_age_final             0.0004034  0.0099123   0.041 0.967675    
## bgc_avg:wflz_birth          0.2622007  0.0739488   3.546 0.000774 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.086 on 59 degrees of freedom
##   (75 observations deleted due to missingness)
## Multiple R-squared:  0.2766, Adjusted R-squared:  0.1907 
## F-statistic: 3.222 on 7 and 59 DF,  p-value: 0.005838
library(interactions)

probe_interaction(model = s, pred = wflz_birth, modx = bgc_avg, interval = T, jnplot = T)
## JOHNSON-NEYMAN INTERVAL
## 
## When bgc_avg is OUTSIDE the interval [2.01, 4.13], the slope of wflz_birth
## is p < .05.
## 
## Note: The range of observed values of bgc_avg is [1.00, 6.00]

## SIMPLE SLOPES ANALYSIS
## 
## Slope of wflz_birth when bgc_avg = 2.093946 (- 1 SD): 
## 
##    Est.   S.E.   t val.      p
## ------- ------ -------- ------
##   -0.26   0.14    -1.90   0.06
## 
## Slope of wflz_birth when bgc_avg = 3.694030 (Mean): 
## 
##   Est.   S.E.   t val.      p
## ------ ------ -------- ------
##   0.16   0.12     1.29   0.20
## 
## Slope of wflz_birth when bgc_avg = 5.294113 (+ 1 SD): 
## 
##   Est.   S.E.   t val.      p
## ------ ------ -------- ------
##   0.58   0.20     2.95   0.00

t <- lm(RSA_alone ~ bgc_avg*average_birth_muac + average_baby_muac.y + child_ga_final + child_age_final+ primiparous, data = data)
summary(t)
## 
## Call:
## lm(formula = RSA_alone ~ bgc_avg * average_birth_muac + average_baby_muac.y + 
##     child_ga_final + child_age_final + primiparous, data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.7700 -0.8155 -0.1340  0.7917  3.1431 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)   
## (Intercept)                16.06888    5.93581   2.707  0.00876 **
## bgc_avg                    -2.48976    0.90167  -2.761  0.00756 **
## average_birth_muac         -0.63636    0.41483  -1.534  0.13011   
## average_baby_muac.y        -0.26815    0.17298  -1.550  0.12619   
## child_ga_final             -0.09651    0.12974  -0.744  0.45974   
## child_age_final             0.01075    0.01084   0.992  0.32500   
## primiparousNon-primiparous  0.28565    0.30502   0.936  0.35265   
## bgc_avg:average_birth_muac  0.22732    0.09144   2.486  0.01563 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.103 on 62 degrees of freedom
##   (72 observations deleted due to missingness)
## Multiple R-squared:  0.2459, Adjusted R-squared:  0.1607 
## F-statistic: 2.888 on 7 and 62 DF,  p-value: 0.0112
interact_plot(t, pred = average_birth_muac, modx = bgc_avg, interval = T, jnplot = T)

sim_slopes(t, pred = average_birth_muac, modx = bgc_avg, interval = T, jnplot = T)
## JOHNSON-NEYMAN INTERVAL
## 
## When bgc_avg is OUTSIDE the interval [-3.54, 4.37], the slope of
## average_birth_muac is p < .05.
## 
## Note: The range of observed values of bgc_avg is [1.00, 6.00]

## SIMPLE SLOPES ANALYSIS
## 
## Slope of average_birth_muac when bgc_avg = 2.162899 (- 1 SD): 
## 
##    Est.   S.E.   t val.      p
## ------- ------ -------- ------
##   -0.14   0.25    -0.58   0.57
## 
## Slope of average_birth_muac when bgc_avg = 3.757143 (Mean): 
## 
##   Est.   S.E.   t val.      p
## ------ ------ -------- ------
##   0.22   0.18     1.21   0.23
## 
## Slope of average_birth_muac when bgc_avg = 5.351387 (+ 1 SD): 
## 
##   Est.   S.E.   t val.      p
## ------ ------ -------- ------
##   0.58   0.21     2.76   0.01
data_w <- data %>% filter(wflz_birth > -4 & wflz_birth < 3)
data_long <- data_w %>%
  pivot_longer(
    cols = c(average_birth_muac, wflz_birth),
    names_to = "Anthropometrics",
    values_to = "Anthropometric_value"
  )

# Add the Arousal State
data_long <- data_long %>%
  mutate(ArousalState = case_when(
    bgc_avg < 4 ~ "Low arousal state",
    bgc_avg >= 4 ~ "High arousal state"
  )) %>%
  filter(!is.na(ArousalState))
# Plot with reshaped data
library(ggplot2)

# Updated plot with non-bold labels and custom theme
ggplot(data_long, aes(x = Anthropometric_value, y = RSA_alone, color = ArousalState)) +
  geom_point(size = 3) +
  geom_smooth(method = "lm", size = 0.8, color = "black", alpha = 0.1) +
  facet_grid(ArousalState ~ Anthropometrics, scales = "free_x", 
             labeller = labeller(Anthropometrics = c(average_birth_muac = "MUAC at birth (cms)", 
                                                     wflz_birth = "Weight-for-length at birth"))) +
  theme_modern() + 
  theme(
    panel.spacing = unit(1.2, "lines"),  # Adds spacing between high and low arousal panels
    strip.text = element_text(size = 14, face = "plain"),  # Keeps panel labels non-bold
    axis.text = element_text(size = 12),
    legend.position = "none",  # Removes the legend
    axis.title = element_text(size = 15, face = "bold")  # Keeps axis titles non-bold
  ) +
  scale_color_manual(values = poster) +
  scale_y_continuous(breaks = seq(1, 6, 0.5), expand = expansion(mult = 0.05)) +  # More detailed RSA scale
 scale_x_continuous(breaks = scales::pretty_breaks(n = 5)) +  # Adjust anthropometric scale
  labs(
    x = "Anthropometrics",
    y = "Infant solo RSA",
    title = "Infant RSA & Anthropometrics by Arousal State"
  )
## `geom_smooth()` using formula = 'y ~ x'

ggsave("AnthroResults.png", width = 6, height = 5, unit = "in", dpi = 300, bg = 'white')
## `geom_smooth()` using formula = 'y ~ x'
#ggsave("pwixsx_leg.png", width = 10, height = 6, unit = "in", dpi = 300, bg = 'white')

Descriptives

#desc <- data %>% select(wflz_birth) %>% describe_distribution()
desc <- data %>% select(child_ga_final) %>% describe_distribution()
desc
## Variable       |  Mean |   SD | IQR |          Range | Skewness | Kurtosis |   n | n_Missing
## --------------------------------------------------------------------------------------------
## child_ga_final | 38.94 | 1.50 |   2 | [30.00, 42.00] |    -1.95 |    10.71 | 119 |        23
desc <- data %>% select(RSA_alone, RSA_tog) %>% describe_distribution()
desc
## Variable  | Mean |   SD |  IQR |        Range | Skewness | Kurtosis |   n | n_Missing
## -------------------------------------------------------------------------------------
## RSA_alone | 2.61 | 1.21 | 1.61 | [0.43, 5.76] |     0.48 |    -0.30 |  83 |        59
## RSA_tog   | 2.58 | 1.03 | 1.55 | [0.09, 4.64] |    -0.05 |    -0.57 | 105 |        37
desc <- data %>% select(BMI) %>% describe_distribution()
desc
## Variable |  Mean |   SD |  IQR |          Range | Skewness | Kurtosis |   n | n_Missing
## ---------------------------------------------------------------------------------------
## BMI      | 23.73 | 4.59 | 3.79 | [16.15, 60.00] |     4.45 |    32.65 | 119 |        23
desc <- data %>% select(average_birth_length, average_birth_muac, average_birth_weight,
                        average_baby_length.y, average_baby_weight.y, average_baby_muac.y) %>% describe_distribution()
desc
## Variable              |  Mean |   SD |  IQR |          Range | Skewness | Kurtosis |   n | n_Missing
## ----------------------------------------------------------------------------------------------------
## average_birth_length  | 49.05 | 2.27 | 2.87 | [37.10, 55.25] |    -1.11 |     6.26 | 108 |        34
## average_birth_muac    |  9.88 | 0.90 | 1.20 |  [8.04, 12.50] |     0.33 |     0.07 | 108 |        34
## average_birth_weight  |  2.96 | 0.49 | 0.58 |   [1.64, 4.66] |     0.48 |     1.76 | 108 |        34
## average_baby_length.y | 55.34 | 2.80 | 3.40 | [47.90, 63.25] |     0.34 |     0.82 | 119 |        23
## average_baby_weight.y |  4.33 | 0.67 | 0.79 |   [2.54, 5.98] |    -0.11 |     0.56 | 119 |        23
## average_baby_muac.y   | 11.89 | 0.99 | 1.20 |  [8.45, 14.75] |    -0.63 |     1.55 | 119 |        23
data %>% select(RSA_alone, RSA_tog) %>% describe_distribution()
## Variable  | Mean |   SD |  IQR |        Range | Skewness | Kurtosis |   n | n_Missing
## -------------------------------------------------------------------------------------
## RSA_alone | 2.61 | 1.21 | 1.61 | [0.43, 5.76] |     0.48 |    -0.30 |  83 |        59
## RSA_tog   | 2.58 | 1.03 | 1.55 | [0.09, 4.64] |    -0.05 |    -0.57 | 105 |        37
# Load necessary library
library(dplyr)

# Calculate median for continuous variables and percentage for gender variable
summary_stats <- data %>%
  summarise(
    median_q102b_guess_age = median(q102b_guess_age, na.rm = TRUE),
    median_child_age_final = median(child_age_final, na.rm = TRUE),
    male_count = sum(child_gender_final == 1, na.rm = TRUE),
    female_count = sum(child_gender_final == 2, na.rm = TRUE),
    male_percentage = (male_count / n()) * 100,
    female_percentage = (female_count / n()) * 100
  )

# Display the results
summary_stats
## # A tibble: 1 × 6
##   median_q102b_guess_age median_child_age_final male_count female_count
##                    <dbl>                  <dbl>      <int>        <int>
## 1                     19                   43.4         70           50
## # ℹ 2 more variables: male_percentage <dbl>, female_percentage <dbl>
data %>% count(child_gender_final)
## # A tibble: 3 × 2
##   child_gender_final     n
##   <dbl+lbl>          <int>
## 1  1 [Male]             70
## 2  2 [Female]           50
## 3 NA                    22
data %>% count(restype)
## # A tibble: 3 × 2
##   restype            n
##   <dbl+lbl>      <int>
## 1  1 [FDMN Camp]    94
## 2  2 [Host]         26
## 3 NA                22